Docsity
Docsity

Prepara tus exámenes
Prepara tus exámenes

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity


Consigue puntos base para descargar
Consigue puntos base para descargar

Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium


Orientación Universidad
Orientación Universidad


NLTK Phyton ejercicio guthernberg, Ejercicios de Filología Inglesa

Asignatura: Nuevas Tecnologias Aplicadas a la Lingüistica., Profesor: MªAngeles Zarcos, Carrera: Filología Inglesa, Universidad: UCA

Tipo: Ejercicios

2014/2015

Subido el 29/07/2015

rgrtg
rgrtg 🇪🇸

4.2

(189)

38 documentos

1 / 3

Toggle sidebar

Esta página no es visible en la vista previa

¡No te pierdas las partes importantes!

bg1
GUTENBERG CORPUS.
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on
win32
Type "copyright", "credits" or "license()" for more information.
>>> import nltk
>>> nltk.corpus.gutenberg.fileids()
['austen-emma.txt', 'austen-persuasion.txt', 'austen-sense.txt', 'bible-kjv.txt', 'blake-poems.txt',
'bryant-stories.txt', 'burgess-busterbrown.txt', 'carroll-alice.txt', 'chesterton-ball.txt', 'chesterton-
brown.txt', 'chesterton-thursday.txt', 'edgeworth-parents.txt', 'melville-moby_dick.txt', 'milton-
paradise.txt', 'shakespeare-caesar.txt', 'shakespeare-hamlet.txt', 'shakespeare-macbeth.txt',
'whitman-leaves.txt']
>>> hamlet = nltk.corpus.gutenberg.words("shakespeare-hamlet.txt")
>>> len(hamlet)
37360
>>> hamlet = nltk.Text(nltk.corpus.gutenberg.words("shakespeare-hamlet.txt"))
>>> hamlet.concordance("ghost")
Displaying 21 of 21 matches:
. Peace , breake thee of : Enter the Ghost . Looke where it comes againe Barn .
: I Charge thee , speake . Exit the Ghost . Mar . ' Tis gone , and will not an
ast , and Romage in the Land . Enter Ghost againe . But soft , behold : Loe , w
' Tis heere Mar . ' Tis gone . Exit Ghost . We do it wrong , being so Maiestic
breach , then the obseruance . Enter Ghost . Hor . Looke my Lord , it comes Ham
s ? wherefore ? what should we doe ? Ghost beckens Hamlet . Hor . It beckons yo
Gentlemen : By Heau ' n , Ile make a Ghost of him that lets me : I say away , g
goe on , Ile follow thee . Exeunt . Ghost & Hamlet . Hor . He waxes desperate
let ' s follow him . Exeunt . Enter Ghost and Hamlet . Ham . Where wilt thou l
render vp my selfe Ham . Alas poore Ghost Gho . Pitty me not , but lend thy se
t vnnaturall Murther Ham . Murther ? Ghost . Murther most foule , as in the bes
s of Loue , May sweepe to my Reuenge Ghost . I finde thee apt , And duller shou
my Propheticke soule : mine Vncle ? Ghost . I that incestuous , that adulterat
vp : Remember thee ? I , thou poore Ghost , while memory holds a seate In this
an arrant knaue Hor . There needs no Ghost my Lord , come from the Graue , to t
this Vision heere : It is an honest Ghost , that let me tell you : For your de
pon my sword , Indeed Gho . Sweare . Ghost cries vnder the Stage . Ham . Ah ha
pf3

Vista previa parcial del texto

¡Descarga NLTK Phyton ejercicio guthernberg y más Ejercicios en PDF de Filología Inglesa solo en Docsity!

GUTENBERG CORPUS.

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win Type "copyright", "credits" or "license()" for more information.

import nltk nltk.corpus.gutenberg.fileids() ['austen-emma.txt', 'austen-persuasion.txt', 'austen-sense.txt', 'bible-kjv.txt', 'blake-poems.txt', 'bryant-stories.txt', 'burgess-busterbrown.txt', 'carroll-alice.txt', 'chesterton-ball.txt', 'chesterton- brown.txt', 'chesterton-thursday.txt', 'edgeworth-parents.txt', 'melville-moby_dick.txt', 'milton- paradise.txt', 'shakespeare-caesar.txt', 'shakespeare-hamlet.txt', 'shakespeare-macbeth.txt', 'whitman-leaves.txt'] hamlet = nltk.corpus.gutenberg.words("shakespeare-hamlet.txt") len(hamlet) 37360 hamlet = nltk.Text(nltk.corpus.gutenberg.words("shakespeare-hamlet.txt")) hamlet.concordance("ghost") Displaying 21 of 21 matches:

. Peace , breake thee of : Enter the Ghost. Looke where it comes againe Barn. : I Charge thee , speake. Exit the Ghost. Mar. ' Tis gone , and will not an ast , and Romage in the Land. Enter Ghost againe. But soft , behold : Loe , w ' Tis heere Mar. ' Tis gone. Exit Ghost. We do it wrong , being so Maiestic breach , then the obseruance. Enter Ghost. Hor. Looke my Lord , it comes Ham s? wherefore? what should we doe? Ghost beckens Hamlet. Hor. It beckons yo Gentlemen : By Heau ' n , Ile make a Ghost of him that lets me : I say away , g goe on , Ile follow thee. Exeunt. Ghost & Hamlet. Hor. He waxes desperate let ' s follow him. Exeunt. Enter Ghost and Hamlet. Ham. Where wilt thou l render vp my selfe Ham. Alas poore Ghost Gho. Pitty me not , but lend thy se t vnnaturall Murther Ham. Murther? Ghost. Murther most foule , as in the bes s of Loue , May sweepe to my Reuenge Ghost. I finde thee apt , And duller shou my Propheticke soule : mine Vncle? Ghost. I that incestuous , that adulterat vp : Remember thee? I , thou poore Ghost , while memory holds a seate In this an arrant knaue Hor. There needs no Ghost my Lord , come from the Graue , to t this Vision heere : It is an honest Ghost , that let me tell you : For your de pon my sword , Indeed Gho. Sweare. Ghost cries vnder the Stage. Ham. Ah ha

t your most neede helpe you : Sweare Ghost. Sweare Ham. Rest , rest perturbed nnell in one speech , It is a damned Ghost that we haue seene : And my Imaginat t in his Pocket Qu. No more. Enter Ghost. Ham. A King of shreds and patches cting of your dread command? Oh say Ghost. Do not forget : this Visitation Is

from nltk.corpus import gutenberg gutenberg.fileids() ['austen-emma.txt', 'austen-persuasion.txt', 'austen-sense.txt', 'bible-kjv.txt', 'blake-poems.txt', 'bryant-stories.txt', 'burgess-busterbrown.txt', 'carroll-alice.txt', 'chesterton-ball.txt', 'chesterton- brown.txt', 'chesterton-thursday.txt', 'edgeworth-parents.txt', 'melville-moby_dick.txt', 'milton- paradise.txt', 'shakespeare-caesar.txt', 'shakespeare-hamlet.txt', 'shakespeare-macbeth.txt', 'whitman-leaves.txt'] macbeth_sentences = gutenberg.sents("shakespeare-macbeth.txt") hamlet_sentences = gutenberg.sents("shakespeare-hamlet.txt") hamlet_sentences [['[', 'The', 'Tragedie', 'of', 'Hamlet', 'by', 'William', 'Shakespeare', '1599', ']'], ['Actus', 'Primus', '.'], ...] import nltk from nltk.book import* *** Introductory Examples for the NLTK Book *** Loading text1, ..., text9 and sent1, ..., sent Type the name of the text or sentence to view it. Type: 'texts()' or 'sents()' to list the materials. text1: Moby Dick by Herman Melville 1851 text2: Sense and Sensibility by Jane Austen 1811 text3: The Book of Genesis text4: Inaugural Address Corpus text5: Chat Corpus text6: Monty Python and the Holy Grail text7: Wall Street Journal text8: Personals Corpus text9: The Man Who Was Thursday by G. K. Chesterton 1908 text1.concordance("ghost") Displaying 13 of 13 matches:

. Kill? The Lord be merciful to his ghost! What ' s that noise there? You , it uttered cries , as some king ' s ghost in supernatural distress. Through i