1.下载书中包含的数据至Python 中

>>> import nltk
>>> nltk.download()
showing info https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml
True

 

安装完成后将book模块中的数据导入

>>> from nltk.book import *
*** Introductory Examples for the NLTK Book ***
Loading text1, ..., text9 and sent1, ..., sent9
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

 2.查找这些text

 

>>> text1
<Text: Moby Dick by Herman Melville 1851>
>>> text2
<Text: Sense and Sensibility by Jane Austen 1811>

 

3. concordance优雅的,优雅的排版(concordance)视图查看某一特定词出现的频率

“monstrous”为例

 1 >>> text1.concordance("monstrous")
 2 Displaying 11 of 11 matches:
 3 ong the former , one was of a most monstrous size . ... This came towards us , 
 4 ON OF THE PSALMS . " Touching that monstrous bulk of the whale or ork we have r
 5 ll over with a heathenish array of monstrous clubs and spears . Some were thick
 6 d as you gazed , and wondered what monstrous cannibal and savage could ever hav
 7 that has survived the flood ; most monstrous and most mountainous ! That Himmal
 8 they might scout at Moby Dick as a monstrous fable , or still worse and more de
 9 th of Radney .'" CHAPTER 55 Of the Monstrous Pictures of Whales . I shall ere l
10 ing Scenes . In connexion with the monstrous pictures of whales , I am strongly
11 ere to enter upon those still more monstrous stories of them which are to be fo
12 ght have been rummaged out of this monstrous cabinet there is no telling . But 
13 of Whale - Bones ; for Whales of a monstrous size are oftentimes cast up dead u

技巧:Alt+P重复上一次输入的文字

            ctrl+up 将光标移动至标题

任务1sense and sensibility中出现“affection”的次数

 

>>> text2.concordance("affection")
Displaying 25 of 79 matches:
, however , and , as a mark of his affection for the three girls , he left them
t . It was very well known that no affection was ever supposed to exist between
deration of politeness or maternal affection on the side of the former , the tw
d the suspicion -- the hope of his affection for me may warrant , without impru
hich forbade the indulgence of his affection . She knew that his mother neither
rd she gave one with still greater affection . Though her late conversation wit
 can never hope to feel or inspire affection again , and if her home be uncomfo
m of the sense , elegance , mutual affection , and domestic comfort of the fami
, and which recommended him to her affection beyond every thing else . His soci
ween the parties might forward the affection of Mr . Willoughby , an equally st
 the most pointed assurance of her affection . Elinor could not be surprised at
he natural consequence of a strong affection in a young and ardent mind . This 
 opinion . But by an appeal to her affection for her mother , by representing t
 every alteration of a place which affection had established as perfect with hi
e will always have one claim of my affection , which no other can possibly shar
f the evening declared at once his affection and happiness . " Shall we see you
ause he took leave of us with less affection than his usual behaviour has shewn
ness ." " I want no proof of their affection ," said Elinor ; " but of their en
onths , without telling her of his affection ;-- that they should part without 
ould be the natural result of your affection for her . She used to be all unres
distinguished Elinor by no mark of affection . Marianne saw and listened with i
th no inclination for expense , no affection for strangers , no profession , an
till distinguished her by the same affection which once she had felt no doubt o
al of her confidence in Edward ' s affection , to the remembrance of every mark
 was made ? Had he never owned his affection to yourself ?" " Oh , no ; but if 

 

 

 

 

任务2the book of Genesis 找出 人物活了多长时间

 

>>> text3.concordance("lived")
Displaying 25 of 38 matches:
ay when they were created . And Adam lived an hundred and thirty years , and be
ughters : And all the days that Adam lived were nine hundred and thirty yea and
nd thirty yea and he died . And Seth lived an hundred and five years , and bega
ve years , and begat Enos : And Seth lived after he begat Enos eight hundred an
welve years : and he died . And Enos lived ninety years , and begat Cainan : An
 years , and begat Cainan : And Enos lived after he begat Cainan eight hundred 
ive years : and he died . And Cainan lived seventy years and begat Mahalaleel :
rs and begat Mahalaleel : And Cainan lived after he begat Mahalaleel eight hund
years : and he died . And Mahalaleel lived sixty and five years , and begat Jar
s , and begat Jared : And Mahalaleel lived after he begat Jared eight hundred a
and five yea and he died . And Jared lived an hundred sixty and two years , and
o years , and he begat Eno And Jared lived after he begat Enoch eight hundred y
 and two yea and he died . And Enoch lived sixty and five years , and begat Met
 ; for God took him . And Methuselah lived an hundred eighty and seven years , 
 , and begat Lamech . And Methuselah lived after he begat Lamech seven hundred 
nd nine yea and he died . And Lamech lived an hundred eighty and two years , an
ch the LORD hath cursed . And Lamech lived after he begat Noah five hundred nin
naan shall be his servant . And Noah lived after the flood three hundred and fi
xad two years after the flo And Shem lived after he begat Arphaxad five hundred
at sons and daughters . And Arphaxad lived five and thirty years , and begat Sa
ars , and begat Salah : And Arphaxad lived after he begat Salah four hundred an
begat sons and daughters . And Salah lived thirty years , and begat Eber : And 
y years , and begat Eber : And Salah lived after he begat Eber four hundred and
 begat sons and daughters . And Eber lived four and thirty years , and begat Pe
y years , and begat Peleg : And Eber lived after he begat Peleg four hundred an

 

任务3the Inaugural Address Corpus 从就职演讲看1789至今 一些诸如 nationterror god 这类词的使用变化

 

>>> text4.concordance("nation")
Displaying 25 of 302 matches:
 to the character of an independent nation seems to have been distinguished by
f Heaven can never be expected on a nation that disregards the eternal rules o
first , the representatives of this nation , then consisting of little more th
, situation , and relations of this nation and country than any which had ever
, prosperity , and happiness of the nation I have acquired an habitual attachm
an be no spectacle presented by any nation more pleasing , more noble , majest
party for its own ends , not of the nation for the national good . If that sol
tures and the people throughout the nation . On this subject it might become m
if a personal esteem for the French nation , formed in a residence of seven ye
f our fellow - citizens by whatever nation , and if success can not be obtaine
y , continue His blessing upon this nation and its Government and give it all 
powers so justly inspire . A rising nation , spread over a wide and fruitful l
ing now decided by the voice of the nation , announced according to the rules 
ars witness to the fact that a just nation is trusted on its word when recours
e union of opinion which gives to a nation the blessing of harmony and the ben
uil suffrage of a free and virtuous nation , would under any circumstances hav
d spirit and united councils of the nation will be safeguards to its honor and
iction that the war with a powerful nation , which forms so prominent a featur
out breaking down the spirit of the nation , destroying all confidence in itse
ed on the military resources of the nation . These resources are amply suffici
the war to an honorable issue . Our nation is in number more than half that of
ndividually have been happy and the nation prosperous . Under this Constitutio
rights , and is able to protect the nation against injustice from foreign powe
 great agricultural interest of the nation prospers under its protection . Loc
ak our Union , and demolish us as a nation . Our distance from Europe and the 
>>> text4.concordance("terror")
Displaying 8 of 8 matches:
menaces , by fraud or violence , by terror , intrigue , or venality , the Gove
ameless , unreasoning , unjustified terror which paralyzes needed efforts to c
ublic seemed frozen by a fatalistic terror , we proved that this is not true .
 to alter that uncertain balance of terror that stays the hand of mankind ' s 
eans freeing all Americans from the terror of runaway living costs . All must 
still . They fuel the fanaticism of terror . And they torment the lives of mil
d maintain a strong defense against terror and destruction . Our children will
k to advance their aims by inducing terror and slaughtering innocents , we say
>>> text4.concordance("god")
Displaying 25 of 98 matches:
eliance on the protection of Almighty God , I shall forthwith commence the duti
humble , acknowledged dependence upon God and His overruling providence . We ha
great office I must humbly invoke the God of our fathers for wisdom and firmnes
d the same Bible and pray to the same God , and each invokes His aid against th
hat any men should dare to ask a just God ' s assistance in wringing their brea
offenses which , in the providence of God , must needs come , but which , havin
butes which the believers in a living God always ascribe to Him ? Fondly do we 
war may speedily pass away . Yet , if God wills that it continue until all the 
r all , with firmness in the right as God gives us to see the right , let us st
the prayers of the nation to Almighty God in behalf of this consummation . Fell
r , they have " followed the light as God gave them to see the light ." They ar
ess their fathers and their fathers ' God that the Union was preserved , that s
the support and blessings of Almighty God . Fellow citizens , in the presence o
ng the power and goodness of Almighty God , who presides over the destiny of na
expect the favor and help of Almighty God -- that He will give to me wisdom , s
 suggestion to enterprise and labor . God has placed upon our head a diadem and
urn than the pledge I now give before God and these witnesses of unreserved and
han human life can escape the laws of God and nature . Manifestly nothing is mo
and invoking the guidance of Almighty God . Our faith teaches that there is no 
re is no safer reliance than upon the God of our fathers , who has so singularl
e the direction and favor of Almighty God . I should shrink from the duties thi
 devolve upon it , and in the fear of God will " take occasion by the hand and 
 citizens and the aid of the Almighty God in the discharge of my responsible du
our heartstrings like some air out of God ' s own presence , where justice and 
 forward - looking men , to my side . God helping me , I will not fail them , i
>>> 
View Code

 

 

任务4:NPS Chat Corpus查看 im,ur,lol这类口语用语使用频率

 

>>> text5.concordance("lol")
Displaying 25 of 822 matches:
ast PART 24 / m boo . 26 / m and sexy lol U115 boo . JOIN PART he drew a girl w
ope he didnt draw a penis PART ewwwww lol & a head between her legs JOIN JOIN s
a bowl i got a blunt an a bong ...... lol JOIN well , glad it worked out my cha
e " PART Hi U121 in ny . ACTION would lol @ U121 . . . but appearently she does
30 make sure u buy a nice ring for U6 lol U7 Hi U115 . ACTION isnt falling for 
 didnt ya hear !!!! PART JOIN geeshhh lol U6 PART hes deaf ppl here dont get it
es nobody here i wanna misbeahve with lol JOIN so read it . thanks U7 .. Im hap
ies want to chat can i talk to him !! lol U121 !!! forwards too lol JOIN ALL PE
k to him !! lol U121 !!! forwards too lol JOIN ALL PErvs ... redirect to U121 '
 loves ME the most i love myself JOIN lol U44 how do u know that what ? jerkett
ng wrong ... i can see it in his eyes lol U20 = fiance Jerketts lmao wtf yah I 
cooler by the minute what 'd I miss ? lol noo there too much work ! why not ?? 
 that mean I want you ? U6 hello room lol U83 and this .. has been the grammar 
 the rule he 's in PM land now though lol ah ok i wont bug em then someone wann
flight to hell :) lmao bbl maybe PART LOL lol U7 it was me , U83 hahah U83 ! 80
ht to hell :) lmao bbl maybe PART LOL lol U7 it was me , U83 hahah U83 ! 808265
082653953 K-Fed got his ass kicked .. Lol . ACTION laughs . i got a first class
 . i got a first class ticket to hell lol U7 JOIN any texas girls in here ? any
 . whats up U155 i was only kidding . lol he 's a douchebag . Poor U121 i 'm bo
 ??? sits with U30 Cum to my shower . lol U121 . ACTION U1370 watches his nads 
 ur nad with a stick . ca u U23 ewwww lol *sniffs* ewwwwww PART U115 ! owww spl
ACTION is resisting . ur female right lol U115 beeeeehave Remember the LAst tim
pm's me . charge that is 1.99 / min . lol @ innocent hahah lol .... yeah LOLOLO
 is 1.99 / min . lol @ innocent hahah lol .... yeah LOLOLOLLL U12 thats not nic
s . lmao no U115 Check my record . :) Lol lick em U7 U23 how old r u lol Way to
>>> text5.concordance("ru")
No matches
>>> text5.concordance("ur")
Displaying 21 of 21 matches:
k up PART no i dont want daughters !! ur annoying . ACTION Now Playing - Cradl
ooo U92 !!!!!! . ACTION U1370 watches ur nad with a stick . ca u U23 ewwww lol
er lip . Meep . ACTION is resisting . ur female right lol U115 beeeeehave Reme
 geeshh ... two kids fighting ! whats ur major i probably sucks in summer too 
II Men scorpions rock ... lol what is ur job me too U11 hehe went to manhattan
e no one i like to say if u have done ur time then that is that U42 Ok U37 , i
hat a ride JOIN ty ty cheers babes .. ur the first to follow up with the pseud
 charger \ty LoL yeah ;-) well i hope ur doing ok .. i 'm dojn fine babe . . g
 gonna rock up soojn and rob u of all ur ' candy ' :) as long as you are happy
genital warts ? LoL moped U28 ?.. ohh ur a real man i had a moped once yup heh
b-day is in 5 days =( PART LOL U35 no ur nawt yup your gay lmao U37 dang come 
 people talk to me anymore oh because ur gay . PART PART . ACTION = U58 . Man 
 om hi U73 heya U7 ! h shit i get all ur money now fawker ok girl lol JOIN ed 
hat tired huh U66 ? lol U75 ... bring ur pillow get comfy U70 yep , off to bed
talked to hi sean . ACTION whispers : ur a douche . who PART . ACTION whispers
ew england usa ? U7 .. it adds wax to ur clothes .. u think cottons breathe ?.
ver knew what flavor to get specially ur towels lol U31 < whistles > U34 U39 I
cks out U7 s pic JOIN PART U41 Hi U41 ur gettin pretty savvy there U39 ahhh ..
om ? brb U30 a week .. heck a day and ur problem there , U30 ??? Hi U34 hartfo
 JOIN U57 Whats really good room JOIN ur telllin me hey any uk girls her ? JOI
JOIN PART JOIN JOIN yea guitar rocker ur kool u lil guitar rocker PART whats e
>>> text5.concordance("im")
Displaying 25 of 149 matches:
                                      im left with this gay name :P PART hey e
what did you but on e-bay i feel like im in the wrong room yeee haw U30 im con
ike im in the wrong room yeee haw U30 im considering changing my nickname to "
 the hell outta my freaking PM box .. Im with my fiance !!!!!!!!!!!!!!!! answe
m impressed . PART hiya room lmao !!! im doin alright thanks omg Finger .. Dee
th lol JOIN so read it . thanks U7 .. Im happy to have my fiance here !! forwa
i didnt me phone you . . . sheesh now im that phone perv guy lets hope not U12
to spain ? i need to go this summer . im a HUGE phone perv ok seriously who wa
an ... . ACTION video tapes . hey U20 Im blind now . ACTION has left the room 
T u got that right , i dont do shit , im the supervisor Hello U165 . hey U165 
 him in the " untouchable " list U115 im good U6 lmao U7 how r u U128 hehe how
can I ask where ya all are from ..... im here in kentucky as I said ... too wi
ic but had to resize and stuff U37 no im an equal oppertunity hater LOL Hi , U
he cover weeeeeeeee thanks U19 ! PART im out in cal now U3 looking at some new
 :) hi U58 lol wb U29 hi U29 U13 .... im down to time now PART Hello U24 , wel
, I 'd never kick you outta my box hi im good thanks U16 yerself ?? PART inter
ke wth . . who are you even ty U34 yw Im glad he 's back . awwww U16 i like ps
 ha U23 !!! wow ... are you the U39 ? Im talkin about all yer typin . . It 's 
... you ??? Apparently , I 'm not U41 im good U23 dear . How are you U23 ~wink
~ U35 ... I love that 5 am phone call im good ... me and eric r back together 
 , I am happy . You know i LuverZ YOU im the same busy busy oh ok then U1 nm l
))) . ACTION stretches . ty U19 Ugh , Im so sore ! Repeatedly , with a big sti
'm a size queen U41 Why U45 ? naw U23 im cheating on you with Jayse hes hawt t
oeer is sum1 gonna ghet fuked up ? :) im always hungry yeah U45 .. i believe i
without first asking permission . U35 im sorry U35 i tried to refrain me too U
>>> 

 


2.类似monstrous的词汇

 

1 >>> text1.similar("monstrous")
2 imperial subtly impalpable pitiable curious abundant perilous
3 trustworthy untoward singular lamentable few determined maddens
4 horrible tyrannical lazy mystifying christian exasperate

 

>>> text2.similar("monstrous")
very exceedingly so heartily a great good amazingly as sweet
remarkably extremely vast

 

通过对以上结果的观察,可见两位作者(Austen、Melville)对monstrous的不同释义(connotation),A认为Monstrous有积极含义,有时有增强(intensifier)功能如very。

3.两个词共享一或多个单词  common_contexts

 

>>> text2.common_contexts(["monstrous","very"])
a_pretty is_pretty a_lucky am_glad be_glad

#注意语法

 

 

 

 

Chat Corpus查看 im,ur,

 

 

转载于:https://www.cnblogs.com/Gailsunset/p/5735406.html

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐