Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> import nltk >>> nltk.download() showing info https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml True >>> nltk.word_tokenize("Hello, world!") ['Hello', ',', 'world', '!'] >>> tale = """It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to heaven, we were all going direct the other way - in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.""" >>> tale 'It was the best of times, it was the worst of times,\nit was the age of wisdom, it was the age of foolishness,\nit was the epoch of belief, it was the epoch of incredulity,\nit was the season of Light, it was the season of Darkness,\nit was the spring of hope, it was the winter of despair,\nwe had everything before us, we had nothing before us,\nwe were all going direct to heaven, we were all going direct\nthe other way - in short, the period was so far like the present\nperiod, that some of its noisiest authorities insisted on its\nbeing received, for good or for evil, in the superlative degree\nof comparison only.' >>> tale.split() ['It', 'was', 'the', 'best', 'of', 'times,', 'it', 'was', 'the', 'worst', 'of', 'times,', 'it', 'was', 'the', 'age', 'of', 'wisdom,', 'it', 'was', 'the', 'age', 'of', 'foolishness,', 'it', 'was', 'the', 'epoch', 'of', 'belief,', 'it', 'was', 'the', 'epoch', 'of', 'incredulity,', 'it', 'was', 'the', 'season', 'of', 'Light,', 'it', 'was', 'the', 'season', 'of', 'Darkness,', 'it', 'was', 'the', 'spring', 'of', 'hope,', 'it', 'was', 'the', 'winter', 'of', 'despair,', 'we', 'had', 'everything', 'before', 'us,', 'we', 'had', 'nothing', 'before', 'us,', 'we', 'were', 'all', 'going', 'direct', 'to', 'heaven,', 'we', 'were', 'all', 'going', 'direct', 'the', 'other', 'way', '-', 'in', 'short,', 'the', 'period', 'was', 'so', 'far', 'like', 'the', 'present', 'period,', 'that', 'some', 'of', 'its', 'noisiest', 'authorities', 'insisted', 'on', 'its', 'being', 'received,', 'for', 'good', 'or', 'for', 'evil,', 'in', 'the', 'superlative', 'degree', 'of', 'comparison', 'only.'] >>> nltk.word_tokenize("Hello, world!") ['Hello', ',', 'world', '!'] >>> nltk.word_tokenize("Hello, it's me, Homer!!!") ['Hello', ',', 'it', "'s", 'me', ',', 'Homer', '!', '!', '!'] >>> "Hello, Madam I'm Adam: the man from Eden...!!") SyntaxError: unmatched ')' >>> nltk.word_tokenize("Hello, Madam I'm Adam: the man from Eden...!!") ['Hello', ',', 'Madam', 'I', "'m", 'Adam', ':', 'the', 'man', 'from', 'Eden', '...', '!', '!'] >>> KeyboardInterrupt >>> nltk.word_tokenize("It ain't over until it's over. It's 5 o'clock now, Mr. Burns.") ['It', 'ai', "n't", 'over', 'until', 'it', "'s", 'over', '.', 'It', "'s", '5', "o'clock", 'now', ',', 'Mr.', 'Burns', '.'] >>> nltk.word_tokenize(tale) ['It', 'was', 'the', 'best', 'of', 'times', ',', 'it', 'was', 'the', 'worst', 'of', 'times', ',', 'it', 'was', 'the', 'age', 'of', 'wisdom', ',', 'it', 'was', 'the', 'age', 'of', 'foolishness', ',', 'it', 'was', 'the', 'epoch', 'of', 'belief', ',', 'it', 'was', 'the', 'epoch', 'of', 'incredulity', ',', 'it', 'was', 'the', 'season', 'of', 'Light', ',', 'it', 'was', 'the', 'season', 'of', 'Darkness', ',', 'it', 'was', 'the', 'spring', 'of', 'hope', ',', 'it', 'was', 'the', 'winter', 'of', 'despair', ',', 'we', 'had', 'everything', 'before', 'us', ',', 'we', 'had', 'nothing', 'before', 'us', ',', 'we', 'were', 'all', 'going', 'direct', 'to', 'heaven', ',', 'we', 'were', 'all', 'going', 'direct', 'the', 'other', 'way', '-', 'in', 'short', ',', 'the', 'period', 'was', 'so', 'far', 'like', 'the', 'present', 'period', ',', 'that', 'some', 'of', 'its', 'noisiest', 'authorities', 'insisted', 'on', 'its', 'being', 'received', ',', 'for', 'good', 'or', 'for', 'evil', ',', 'in', 'the', 'superlative', 'degree', 'of', 'comparison', 'only', '.'] >>> taletoks = nltk.word_tokenize(tale) >>> len(taletoks) 138 >>> nltk.sent_tokenize(tale) ['It was the best of times, it was the worst of times,\nit was the age of wisdom, it was the age of foolishness,\nit was the epoch of belief, it was the epoch of incredulity,\nit was the season of Light, it was the season of Darkness,\nit was the spring of hope, it was the winter of despair,\nwe had everything before us, we had nothing before us,\nwe were all going direct to heaven, we were all going direct\nthe other way - in short, the period was so far like the present\nperiod, that some of its noisiest authorities insisted on its\nbeing received, for good or for evil, in the superlative degree\nof comparison only.'] >>> taletoks ['It', 'was', 'the', 'best', 'of', 'times', ',', 'it', 'was', 'the', 'worst', 'of', 'times', ',', 'it', 'was', 'the', 'age', 'of', 'wisdom', ',', 'it', 'was', 'the', 'age', 'of', 'foolishness', ',', 'it', 'was', 'the', 'epoch', 'of', 'belief', ',', 'it', 'was', 'the', 'epoch', 'of', 'incredulity', ',', 'it', 'was', 'the', 'season', 'of', 'Light', ',', 'it', 'was', 'the', 'season', 'of', 'Darkness', ',', 'it', 'was', 'the', 'spring', 'of', 'hope', ',', 'it', 'was', 'the', 'winter', 'of', 'despair', ',', 'we', 'had', 'everything', 'before', 'us', ',', 'we', 'had', 'nothing', 'before', 'us', ',', 'we', 'were', 'all', 'going', 'direct', 'to', 'heaven', ',', 'we', 'were', 'all', 'going', 'direct', 'the', 'other', 'way', '-', 'in', 'short', ',', 'the', 'period', 'was', 'so', 'far', 'like', 'the', 'present', 'period', ',', 'that', 'some', 'of', 'its', 'noisiest', 'authorities', 'insisted', 'on', 'its', 'being', 'received', ',', 'for', 'good', 'or', 'for', 'evil', ',', 'in', 'the', 'superlative', 'degree', 'of', 'comparison', 'only', '.'] >>> set(taletoks) {'epoch', 'degree', '.', '-', 'insisted', 'in', 'were', 'short', 'being', 'Darkness', 'way', 'good', 'the', 'times', 'wisdom', 'hope', 'far', 'its', 'It', 'was', 'nothing', 'Light', 'heaven', 'season', 'received', 'winter', 'it', 'to', 'we', 'us', 'or', 'period', 'comparison', 'had', 'going', 'that', 'before', 'incredulity', 'despair', 'all', 'direct', 'best', 'of', 'everything', 'noisiest', 'spring', 'like', 'other', 'superlative', 'evil', 'worst', 'so', 'age', 'for', 'authorities', 'present', 'on', 'foolishness', ',', 'some', 'only', 'belief'} >>> len(set(taletoks)) 62 >>> nltk.FreqDist(taletoks) FreqDist({',': 17, 'the': 14, 'of': 12, 'was': 11, 'it': 9, 'we': 4, 'times': 2, 'age': 2, 'epoch': 2, 'season': 2, ...}) >>> talefreq = nltk.FreqDist(taletoks) >>> talefreq['it'] 9 >>> talefreq['of'] 12 >>> talefreq['the'] 14 >>> talefreq.keys() dict_keys(['It', 'was', 'the', 'best', 'of', 'times', ',', 'it', 'worst', 'age', 'wisdom', 'foolishness', 'epoch', 'belief', 'incredulity', 'season', 'Light', 'Darkness', 'spring', 'hope', 'winter', 'despair', 'we', 'had', 'everything', 'before', 'us', 'nothing', 'were', 'all', 'going', 'direct', 'to', 'heaven', 'other', 'way', '-', 'in', 'short', 'period', 'so', 'far', 'like', 'present', 'that', 'some', 'its', 'noisiest', 'authorities', 'insisted', 'on', 'being', 'received', 'for', 'good', 'or', 'evil', 'superlative', 'degree', 'comparison', 'only', '.']) >>> talefreq.values() dict_values([1, 11, 14, 1, 12, 2, 17, 9, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 4, 2, 1, 2, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]) >>> talefreq.items() dict_items([('It', 1), ('was', 11), ('the', 14), ('best', 1), ('of', 12), ('times', 2), (',', 17), ('it', 9), ('worst', 1), ('age', 2), ('wisdom', 1), ('foolishness', 1), ('epoch', 2), ('belief', 1), ('incredulity', 1), ('season', 2), ('Light', 1), ('Darkness', 1), ('spring', 1), ('hope', 1), ('winter', 1), ('despair', 1), ('we', 4), ('had', 2), ('everything', 1), ('before', 2), ('us', 2), ('nothing', 1), ('were', 2), ('all', 2), ('going', 2), ('direct', 2), ('to', 1), ('heaven', 1), ('other', 1), ('way', 1), ('-', 1), ('in', 2), ('short', 1), ('period', 2), ('so', 1), ('far', 1), ('like', 1), ('present', 1), ('that', 1), ('some', 1), ('its', 2), ('noisiest', 1), ('authorities', 1), ('insisted', 1), ('on', 1), ('being', 1), ('received', 1), ('for', 2), ('good', 1), ('or', 1), ('evil', 1), ('superlative', 1), ('degree', 1), ('comparison', 1), ('only', 1), ('.', 1)]) >>> talefreq.most_common(5) [(',', 17), ('the', 14), ('of', 12), ('was', 11), ('it', 9)] >>> dir(talefreq) ['B', 'N', 'Nr', '_N', '__add__', '__and__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__iand__', '__init__', '__init_subclass__', '__ior__', '__isub__', '__iter__', '__le__', '__len__', '__lt__', '__missing__', '__module__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__weakref__', '_cumulative_frequencies', '_keep_positive', 'clear', 'copy', 'elements', 'freq', 'fromkeys', 'get', 'hapaxes', 'items', 'keys', 'max', 'most_common', 'pformat', 'plot', 'pop', 'popitem', 'pprint', 'r_Nr', 'setdefault', 'subtract', 'tabulate', 'update', 'values'] >>> talefreq.hapaxes() ['It', 'best', 'worst', 'wisdom', 'foolishness', 'belief', 'incredulity', 'Light', 'Darkness', 'spring', 'hope', 'winter', 'despair', 'everything', 'nothing', 'to', 'heaven', 'other', 'way', '-', 'short', 'so', 'far', 'like', 'present', 'that', 'some', 'noisiest', 'authorities', 'insisted', 'on', 'being', 'received', 'good', 'or', 'evil', 'superlative', 'degree', 'comparison', 'only', '.'] >>> talefreq.tabulate() , the of was it we times age epoch season had before us were all going direct in period its for It best worst wisdom foolishness belief incredulity Light Darkness spring hope winter despair everything nothing to heaven other way - short so far like present that some noisiest authorities insisted on being received good or evil superlative degree comparison only . 17 14 12 11 9 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 >>> talefreq.max() ',' >>> talefreq.items() dict_items([('It', 1), ('was', 11), ('the', 14), ('best', 1), ('of', 12), ('times', 2), (',', 17), ('it', 9), ('worst', 1), ('age', 2), ('wisdom', 1), ('foolishness', 1), ('epoch', 2), ('belief', 1), ('incredulity', 1), ('season', 2), ('Light', 1), ('Darkness', 1), ('spring', 1), ('hope', 1), ('winter', 1), ('despair', 1), ('we', 4), ('had', 2), ('everything', 1), ('before', 2), ('us', 2), ('nothing', 1), ('were', 2), ('all', 2), ('going', 2), ('direct', 2), ('to', 1), ('heaven', 1), ('other', 1), ('way', 1), ('-', 1), ('in', 2), ('short', 1), ('period', 2), ('so', 1), ('far', 1), ('like', 1), ('present', 1), ('that', 1), ('some', 1), ('its', 2), ('noisiest', 1), ('authorities', 1), ('insisted', 1), ('on', 1), ('being', 1), ('received', 1), ('for', 2), ('good', 1), ('or', 1), ('evil', 1), ('superlative', 1), ('degree', 1), ('comparison', 1), ('only', 1), ('.', 1)]) >>> for (w,c) in talefreq.items(): if c>=10: print(w, "occurs", c, "times.") was occurs 11 times. the occurs 14 times. of occurs 12 times. , occurs 17 times. >>> for (w,c) in talefreq.items(): if len(w)>=10: print(w, "occurs", c, "times.") foolishness occurs 1 times. incredulity occurs 1 times. everything occurs 1 times. authorities occurs 1 times. superlative occurs 1 times. comparison occurs 1 times. >>> for (w,c) in talefreq.items(): if len(w)>=10: print(w, len(w), "occurs", c, "times.") foolishness 11 occurs 1 times. incredulity 11 occurs 1 times. everything 10 occurs 1 times. authorities 11 occurs 1 times. superlative 11 occurs 1 times. comparison 10 occurs 1 times. >>> fname = "C:\Users\Jane Eyre\Documents\ling1330\gettysburg_address.txt" SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape >>> fname = "C:/Users/Jane Eyre/Documents/ling1330/gettysburg_address.txt" >>> myfile = open(fname, 'r') >>> gtxt = myfile.read() >>> myfile.close() >>> gtxt 'Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal.\n\nNow we are engaged in a great civil war, testing whether that nation, or any nation, so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.\n\nBut, in a larger sense, we can not dedicate, we can not consecrate, we can not hallow this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us - that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion - that we here highly resolve that these dead shall not have died in vain - that this nation, under God, shall have a new birth of freedom - and that government of the people, by the people, for the people, shall not perish from the earth.\n' >>> len(gtxt) 1465 >>> nltk.word_tokenize(gtxt) ['Four', 'score', 'and', 'seven', 'years', 'ago', 'our', 'fathers', 'brought', 'forth', 'on', 'this', 'continent', 'a', 'new', 'nation', ',', 'conceived', 'in', 'liberty', ',', 'and', 'dedicated', 'to', 'the', 'proposition', 'that', 'all', 'men', 'are', 'created', 'equal', '.', 'Now', 'we', 'are', 'engaged', 'in', 'a', 'great', 'civil', 'war', ',', 'testing', 'whether', 'that', 'nation', ',', 'or', 'any', 'nation', ',', 'so', 'conceived', 'and', 'so', 'dedicated', ',', 'can', 'long', 'endure', '.', 'We', 'are', 'met', 'on', 'a', 'great', 'battle-field', 'of', 'that', 'war', '.', 'We', 'have', 'come', 'to', 'dedicate', 'a', 'portion', 'of', 'that', 'field', ',', 'as', 'a', 'final', 'resting', 'place', 'for', 'those', 'who', 'here', 'gave', 'their', 'lives', 'that', 'that', 'nation', 'might', 'live', '.', 'It', 'is', 'altogether', 'fitting', 'and', 'proper', 'that', 'we', 'should', 'do', 'this', '.', 'But', ',', 'in', 'a', 'larger', 'sense', ',', 'we', 'can', 'not', 'dedicate', ',', 'we', 'can', 'not', 'consecrate', ',', 'we', 'can', 'not', 'hallow', 'this', 'ground', '.', 'The', 'brave', 'men', ',', 'living', 'and', 'dead', ',', 'who', 'struggled', 'here', ',', 'have', 'consecrated', 'it', ',', 'far', 'above', 'our', 'poor', 'power', 'to', 'add', 'or', 'detract', '.', 'The', 'world', 'will', 'little', 'note', ',', 'nor', 'long', 'remember', 'what', 'we', 'say', 'here', ',', 'but', 'it', 'can', 'never', 'forget', 'what', 'they', 'did', 'here', '.', 'It', 'is', 'for', 'us', 'the', 'living', ',', 'rather', ',', 'to', 'be', 'dedicated', 'here', 'to', 'the', 'unfinished', 'work', 'which', 'they', 'who', 'fought', 'here', 'have', 'thus', 'far', 'so', 'nobly', 'advanced', '.', 'It', 'is', 'rather', 'for', 'us', 'to', 'be', 'here', 'dedicated', 'to', 'the', 'great', 'task', 'remaining', 'before', 'us', '-', 'that', 'from', 'these', 'honored', 'dead', 'we', 'take', 'increased', 'devotion', 'to', 'that', 'cause', 'for', 'which', 'they', 'gave', 'the', 'last', 'full', 'measure', 'of', 'devotion', '-', 'that', 'we', 'here', 'highly', 'resolve', 'that', 'these', 'dead', 'shall', 'not', 'have', 'died', 'in', 'vain', '-', 'that', 'this', 'nation', ',', 'under', 'God', ',', 'shall', 'have', 'a', 'new', 'birth', 'of', 'freedom', '-', 'and', 'that', 'government', 'of', 'the', 'people', ',', 'by', 'the', 'people', ',', 'for', 'the', 'people', ',', 'shall', 'not', 'perish', 'from', 'the', 'earth', '.'] >>> nltk.word_tokenize(gtxt.lower()) ['four', 'score', 'and', 'seven', 'years', 'ago', 'our', 'fathers', 'brought', 'forth', 'on', 'this', 'continent', 'a', 'new', 'nation', ',', 'conceived', 'in', 'liberty', ',', 'and', 'dedicated', 'to', 'the', 'proposition', 'that', 'all', 'men', 'are', 'created', 'equal', '.', 'now', 'we', 'are', 'engaged', 'in', 'a', 'great', 'civil', 'war', ',', 'testing', 'whether', 'that', 'nation', ',', 'or', 'any', 'nation', ',', 'so', 'conceived', 'and', 'so', 'dedicated', ',', 'can', 'long', 'endure', '.', 'we', 'are', 'met', 'on', 'a', 'great', 'battle-field', 'of', 'that', 'war', '.', 'we', 'have', 'come', 'to', 'dedicate', 'a', 'portion', 'of', 'that', 'field', ',', 'as', 'a', 'final', 'resting', 'place', 'for', 'those', 'who', 'here', 'gave', 'their', 'lives', 'that', 'that', 'nation', 'might', 'live', '.', 'it', 'is', 'altogether', 'fitting', 'and', 'proper', 'that', 'we', 'should', 'do', 'this', '.', 'but', ',', 'in', 'a', 'larger', 'sense', ',', 'we', 'can', 'not', 'dedicate', ',', 'we', 'can', 'not', 'consecrate', ',', 'we', 'can', 'not', 'hallow', 'this', 'ground', '.', 'the', 'brave', 'men', ',', 'living', 'and', 'dead', ',', 'who', 'struggled', 'here', ',', 'have', 'consecrated', 'it', ',', 'far', 'above', 'our', 'poor', 'power', 'to', 'add', 'or', 'detract', '.', 'the', 'world', 'will', 'little', 'note', ',', 'nor', 'long', 'remember', 'what', 'we', 'say', 'here', ',', 'but', 'it', 'can', 'never', 'forget', 'what', 'they', 'did', 'here', '.', 'it', 'is', 'for', 'us', 'the', 'living', ',', 'rather', ',', 'to', 'be', 'dedicated', 'here', 'to', 'the', 'unfinished', 'work', 'which', 'they', 'who', 'fought', 'here', 'have', 'thus', 'far', 'so', 'nobly', 'advanced', '.', 'it', 'is', 'rather', 'for', 'us', 'to', 'be', 'here', 'dedicated', 'to', 'the', 'great', 'task', 'remaining', 'before', 'us', '-', 'that', 'from', 'these', 'honored', 'dead', 'we', 'take', 'increased', 'devotion', 'to', 'that', 'cause', 'for', 'which', 'they', 'gave', 'the', 'last', 'full', 'measure', 'of', 'devotion', '-', 'that', 'we', 'here', 'highly', 'resolve', 'that', 'these', 'dead', 'shall', 'not', 'have', 'died', 'in', 'vain', '-', 'that', 'this', 'nation', ',', 'under', 'god', ',', 'shall', 'have', 'a', 'new', 'birth', 'of', 'freedom', '-', 'and', 'that', 'government', 'of', 'the', 'people', ',', 'by', 'the', 'people', ',', 'for', 'the', 'people', ',', 'shall', 'not', 'perish', 'from', 'the', 'earth', '.'] >>> gtoks = nltk.word_tokenize(gtxt.lower()) >>> gtoks ['four', 'score', 'and', 'seven', 'years', 'ago', 'our', 'fathers', 'brought', 'forth', 'on', 'this', 'continent', 'a', 'new', 'nation', ',', 'conceived', 'in', 'liberty', ',', 'and', 'dedicated', 'to', 'the', 'proposition', 'that', 'all', 'men', 'are', 'created', 'equal', '.', 'now', 'we', 'are', 'engaged', 'in', 'a', 'great', 'civil', 'war', ',', 'testing', 'whether', 'that', 'nation', ',', 'or', 'any', 'nation', ',', 'so', 'conceived', 'and', 'so', 'dedicated', ',', 'can', 'long', 'endure', '.', 'we', 'are', 'met', 'on', 'a', 'great', 'battle-field', 'of', 'that', 'war', '.', 'we', 'have', 'come', 'to', 'dedicate', 'a', 'portion', 'of', 'that', 'field', ',', 'as', 'a', 'final', 'resting', 'place', 'for', 'those', 'who', 'here', 'gave', 'their', 'lives', 'that', 'that', 'nation', 'might', 'live', '.', 'it', 'is', 'altogether', 'fitting', 'and', 'proper', 'that', 'we', 'should', 'do', 'this', '.', 'but', ',', 'in', 'a', 'larger', 'sense', ',', 'we', 'can', 'not', 'dedicate', ',', 'we', 'can', 'not', 'consecrate', ',', 'we', 'can', 'not', 'hallow', 'this', 'ground', '.', 'the', 'brave', 'men', ',', 'living', 'and', 'dead', ',', 'who', 'struggled', 'here', ',', 'have', 'consecrated', 'it', ',', 'far', 'above', 'our', 'poor', 'power', 'to', 'add', 'or', 'detract', '.', 'the', 'world', 'will', 'little', 'note', ',', 'nor', 'long', 'remember', 'what', 'we', 'say', 'here', ',', 'but', 'it', 'can', 'never', 'forget', 'what', 'they', 'did', 'here', '.', 'it', 'is', 'for', 'us', 'the', 'living', ',', 'rather', ',', 'to', 'be', 'dedicated', 'here', 'to', 'the', 'unfinished', 'work', 'which', 'they', 'who', 'fought', 'here', 'have', 'thus', 'far', 'so', 'nobly', 'advanced', '.', 'it', 'is', 'rather', 'for', 'us', 'to', 'be', 'here', 'dedicated', 'to', 'the', 'great', 'task', 'remaining', 'before', 'us', '-', 'that', 'from', 'these', 'honored', 'dead', 'we', 'take', 'increased', 'devotion', 'to', 'that', 'cause', 'for', 'which', 'they', 'gave', 'the', 'last', 'full', 'measure', 'of', 'devotion', '-', 'that', 'we', 'here', 'highly', 'resolve', 'that', 'these', 'dead', 'shall', 'not', 'have', 'died', 'in', 'vain', '-', 'that', 'this', 'nation', ',', 'under', 'god', ',', 'shall', 'have', 'a', 'new', 'birth', 'of', 'freedom', '-', 'and', 'that', 'government', 'of', 'the', 'people', ',', 'by', 'the', 'people', ',', 'for', 'the', 'people', ',', 'shall', 'not', 'perish', 'from', 'the', 'earth', '.'] >>> len(gtoks) 309 >>> set(gtoks) {'struggled', 'resolve', 'can', 'people', 'earth', 'portion', 'come', 'by', 'hallow', 'fought', 'years', 'testing', 'brave', 'ago', 'measure', 'this', 'great', 'rather', 'live', 'work', 'say', 'men', 'power', 'god', 'before', 'all', 'liberty', 'ground', 'birth', 'unfinished', 'they', 'so', 'as', 'whether', 'for', 'larger', 'which', 'add', 'world', 'living', 'resting', 'forget', 'field', 'battle-field', '.', 'dedicated', '-', 'consecrated', 'brought', 'fitting', 'cause', 'engaged', 'four', 'thus', 'our', 'advanced', 'civil', 'lives', 'under', 'to', 'final', 'it', 'created', 'gave', 'above', 'take', 'war', 'that', 'place', 'full', 'highly', 'last', 'nor', 'on', 'consecrate', 'did', 'died', 'little', 'nation', 'remaining', 'the', 'sense', 'honored', 'government', 'dedicate', 'we', 'their', 'or', 'us', 'increased', 'altogether', 'poor', 'forth', 'continent', 'any', 'might', 'endure', 'a', 'have', 'those', 'perish', 'conceived', 'should', 'and', 'met', 'never', 'seven', 'in', 'these', 'remember', 'shall', 'far', 'new', 'note', 'be', 'vain', 'proposition', 'long', 'task', 'will', 'who', 'what', 'equal', 'not', 'devotion', 'here', 'freedom', 'of', 'do', 'but', 'nobly', 'is', 'fathers', 'score', 'proper', 'dead', 'detract', ',', 'from', 'are', 'now'} >>> len(set(gtoks)) 141 >>> nltk.FreqDist(gtoks) FreqDist({',': 24, 'that': 13, 'the': 11, '.': 10, 'we': 10, 'to': 8, 'here': 8, 'a': 7, 'and': 6, 'nation': 5, ...}) >>> gfreq = nltk.FreqDist(gtoks) >>> gfreq['the'] 11 >>> gfreq.most_common(20) [(',', 24), ('that', 13), ('the', 11), ('.', 10), ('we', 10), ('to', 8), ('here', 8), ('a', 7), ('and', 6), ('nation', 5), ('can', 5), ('of', 5), ('have', 5), ('for', 5), ('it', 5), ('not', 5), ('this', 4), ('in', 4), ('dedicated', 4), ('-', 4)] >>> gfreq['the'] 11 >>> gfreq.freq('the') 0.03559870550161812 >>>