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 将光标移动至标题
任务1:sense 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
任务2:the 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
任务3:the Inaugural Address Corpus 从就职演讲看1789至今 一些诸如 nation、terror 、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 >>>