In [3]:
import nltk

%matplotlib inline

In [4]:
import os

from nltk.corpus.reader.plaintext import PlaintextCorpusReader

corpusdir = 'data/texts/' # Directory of corpus.
corpus0 = PlaintextCorpusReader(corpusdir, '.*')
corpus  = nltk.Text(corpus0.words())

In [3]:
corpus.concordance('girls')


Displaying 25 of 25 matches:
hree nees for president , upperclass girls , who have been in residence in this
lections held . b . The names of the girls nominated shall be posted at least t
be elected each term . BY - LAWS 1 . Girls are required to respect rulings rega
 . rules become effective as soon as girls enter college houses . At the beginn
t - of - town permit for upper class girls . d . Absences from a college reside
blication staffs . Offices , held by girls , which come under Student Council r
- 15 nees for president , upperclass girls , who have been in residence in this
tions held . 16 b . The names of the girls nominated shall be posted at least t
d by Judiciary Board . BY - LAWS I . Girls are required to respect rulings rega
 . rules become effective as soon as girls enter college houses . At the beginn
 over - night absences . Upper class girls need special out - of - town permits
blication staffs . Offices , held by girls , which come under Student Council r
 we can be truly willing to have all girls adopt and imitate our ways . 3 ' Wel
, lockers , and even an iron so that girls who live in Lansing or East Lansing 
 Lansing may freshen up . The town - girls have a regular organization and A . 
the beauty of seeing a procession of girls winding across the campus walks , ca
ret . You know what ? Almost all the girls in the dorm went to the mixer tonigh
t around to all the houses , and the girls were all so nice to us . 14 Sept . 3
 Marge and I went with a bU ! lch of girls to the barbecue . It was such fun , 
We were all so excited , because the girls serenaded her last night . June ll -
 nominees for president , upperclass girls , who have been in residence in this
lections held . b . The names of the girls nominated shall be posted at least t
 shall be elected each term . 38 I . Girls are required to respect rulings ing 
ng registered with the hostess . 7 . Girls accepting employment for special eve
ome for any night absences . All new girls need special out - of - lown permits

In [13]:
corpus.concordance("'", lines=all)


Displaying 152 of 152 matches:
 of the Class oj 1941 this handbook is ' dedicated by the Associated Women Stud
n Hellenic . Chairman of Spartan Women ' s League . President of Y . W . C . A 
ers to your perplexing questions . Won ' t you come in early and see us ? Some 
be in charge of card catalog and women ' s ity calendar . d . The Secretary sha
n Hellenic , Chairman of Spartan Women ' s League , President of Y . W . C . A 
onomics Club , Chairman of Freshman Le ' cture , and President of Tower Guard .
mbers of the Associated Women Students ' Council shall be made by the preceding
d shall read their reports of the year ' s work . The ports of the other office
r others wishing cooperation for women ' s zations . Section 2 . The duties of 
en hours : 1 . Mid - week hours : 11 o ' clock sion until Friday of Freshman We
ive no unsatisfactory reports have 9 o ' clock permission . Nine o ' clock perm
s have 9 o ' clock permission . Nine o ' clock permission prevails Winter and S
 nesday , and Thursday nights . 17 2 . ' Sunday : 9 : 30 , all terms . 3 . Frid
all not go to fraternity houses or men ' s club rooms where an proved chaperone
 meet with the approval of the student ' s family and that hours are within A .
nt of A . W . S . or the Dean of Women ' s office . Freshmen must have in addit
 Hellenic . President of Spartan Women ' s League . Presidents of Social Sorori
 dormitory the first aide on the first ' floor takes command . 2 . The aides on
oor takes command . 2 . The aides on e ' ach floor are to be responsible for th
 of the Administration building . Houl ' s are from 8 to 12 a . m . and from 1 
anhellenic . Chairman of Spartan Women ' s League . President of Y . W . C . A 
o knows their meaning and this college ' s history before you violate them . We
zation - it is your organization .. We ' re going to need your active interest 
place our hopes : that your four years ' stay may be profitable to you and to y
be in charge of card catalog and women ' s ity calendar . d . The Secretary sha
anhellenic , Chairman of Spartan Women ' s League , President of Y . W . C . A 
mbers of the Associated Women Students ' Council shall be made by the preceding
d shall read their reports of the year ' s work . The reports of the other offi
r others wishing cooperation for women ' s organizations . 14 Section 2 . The d
 CONSTITUTION 1 . Organization . Women ' s houses shall have a House Council an
bers of each dormitory . The Judiciary ' Board members shall take charge of the
en hours : 1 . Mid - week hours : 11 o ' clock sion until Friday of Freshman We
econd time to one student . 4 . Guests ' visiting hours in dormitories and hous
all not go to fraternity houses or men ' s rooms where an approved chaperon is 
 meet with the approval of the student ' s family and that hours are within A .
nhellenic . President of Spartan Women ' s League . Presidents of Social Sorori
 COllEGE East lansing . Michigan , 4 . ' W . s . HANDBOOK FOR WOMEN STUDENTS ..
across the hall from the Dean of Women ' s office . Hours are from 8 to 12 a . 
l girls adopt and imitate our ways . 3 ' Welcome · I ; wm · Ł . . < lite 01 ' k
3 ' Welcome · I ; wm · Ł . . < lite 01 ' k / 0IHeH . MISS ELISABETH CONRAD " Gr
f at any time we of this Dean of Women ' s Office can be of assistance to you i
t on Michigan State campus . While you ' re here , we hope these will be the be
ll be the best years of your life . It ' s up to you that they are . We ' ll he
 . It ' s up to you that they are . We ' ll help you . Upon registration , ever
verning body of Michigan State College ' s undergraduate women . All campus org
ll want to know you . Help us , and we ' ll do everything we can to help you . 
nic Council President of Spartan Women ' s League President of Y . W . C . A . 
 . A . President of Mortar Board Women ' s Editor of Michigan State News Senior
 determine final ratings . These women ' s offices have been estimated cording 
 of Vocational Guidance 5 . Panhelleni ' c chairman 6 . Chairman of Freshman co
ecial petition ) 10 $ 1VWeIf Uf , IJ . ' W . $. Each fall A . W . S . sponsors 
 . has just completed this year a girl ' s room , up on the fourth floor of the
fice , located . in the Administration ' building , just across from the Dean o
g , just across from the Dean of Women ' s office . Here we have our filing cab
 . W . S . is busy helping other women ' s organizations carryon their activiti
ht . 12 Ł Ł Sept . 23 - Diary dear , I ' m all ajimbo over State . My roommate 
 m all ajimbo over State . My roommate ' s awfully nice and she ' s got the cut
. My roommate ' s awfully nice and she ' s got the cutest accent ' cause she ' 
nice and she ' s got the cutest accent ' cause she ' s from down south . And I 
 ' s got the cutest accent ' cause she ' s from down south . And I finally met 
ly met my Counselor --- the junior who ' s been writing to me telling me the wh
g a coed . Sept . 27 - Shh , diary . I ' ve got a secret . You know what ? Almo
mest sophomore walked me home , and he ' s taking me to the show Saturday night
and walked and walked today . If I don ' t know this campus now . What a yawn .
now this campus now . What a yawn . It ' s wonderful to have such a darling roo
and such a swell roommate ! Anyway , I ' ve been all fied n ' everything , so n
mate ! Anyway , I ' ve been all fied n ' everything , so now to bed . Sept . 29
o now to bed . Sept . 29 - Jean , that ' s my ' roomy ', diary , and I are so g
o bed . Sept . 29 - Jean , that ' s my ' roomy ', diary , and I are so glad we 
nice to us . 14 Sept . 30 -- The day I ' ve been dreaming about has finally com
t ever . A freshman pot ( Diary , that ' s a green hat ) missed the bonfire , s
rganization booths were so clever ! It ' s so hard to decide what to join . 15 
 so hard to decide what to join . 15 I ' m going to join Spartan Women ' s Leag
. 15 I ' m going to join Spartan Women ' s League and Women ' s Athletic Associ
oin Spartan Women ' s League and Women ' s Athletic Association and maybe I ' l
n ' s Athletic Association and maybe I ' ll take in some others next term . The
ider and dougHnuts here are the best I ' ve ever tasted , they must be a specia
 Feb . 14 - 0h , wonder of wonders ! I ' m going to the J - Hop next weekend ! 
 J - Hop next weekend ! We have four o ' clock permission , and I ' ve heard ru
have four o ' clock permission , and I ' ve heard rumors that the favors and de
 bags . This will be the first year it ' s been held in the new auditorium . Fe
 to his fraternity dinner - dance . He ' s a smooth dancer and seems like lots 
ertainly crossed --- tightly , too . I ' m so glad that Jean ' s S . P ., a 16 
ightly , too . I ' m so glad that Jean ' s S . P ., a 16 senior , has asked her
 so handsome in their uniforms , but I ' ll bet my striped pajamas that they we
 which is held every year by the women ' s h 0 nor societies , Mortar Board and
eties , Mortar Board and Tower G u a l ' d . They tap new bers for the coming y
ast night . June ll - Diary dear , you ' re going to be neglected _ -- commence
ing canoeing , and dancing , and I can ' t make up 17 my mind whether I want to
 I want to see summer , even though it ' s vacation . I ' ll be anxiously looki
mmer , even though it ' s vacation . I ' ll be anxiously looking forward to Sep
 again . 18 So over and over again you ' ve told the family purse holder and hi
ly purse holder and hind - you that it ' s an education you crave from Michigan
 " in . LOGIC : The major premise : it ' s not what you know but whom you know 
know the right people . To do that you ' ve got to look worth knowing , so your
 ability ( you know what we mean ); it ' s up to you . To ' get started upward 
 what we mean ); it ' s up to you . To ' get started upward in your four colleg
 should know the essential dos and don ' ts of college dress and etiquette ; yo
or a velvet charmer whose derriere isn ' t luminous . Visiting the library and 
 cotton shirt , and saddles . Or if it ' s sweltering hot ( first weeks always 
ot ( first weeks always fool us ), you ' ll be able to wear summer duds , perha
 memorize a few Home Ec principles . F ' rinstance : 1 . A slip straggling unde
 error , and even Gertrude Steins aren ' t excused therefore . So , if your ski
pondingly short . 2 . Full skirts aren ' t as subject to sit - itis as straight
ses , etc ., but the ironing board won ' t be your chief love at college . 3 . 
 chief love at college . 3 . We wouldn ' t dare suggest that you clean your sad
nd other species of flatties till they ' re actually white , but we do hint at 
. Clean , press , and repair last fall ' s clothes ; it ' s not at all necessar
 and repair last fall ' s clothes ; it ' s not at all necessary to get new clot
thes for college . The dress that hasn ' t worn out after four years in Senior 
klin Field and exude pride for Bachman ' s boys . For home games we cheer in ca
lly have regulation suits , so you won ' t have to worry on this score . MODERN
o help the good impression we know you ' ll make : If you don ' t smoke , don '
ion we know you ' ll make : If you don ' t smoke , don ' t refuse cigarettes wi
' ll make : If you don ' t smoke , don ' t refuse cigarettes with a holier - th
you , no " serves better . Second , it ' s an invaluable asset if you can carry
 examination and chit - chat , but don ' t do all the carrying , listen too . A
 new men . . . powdering your roommate ' s back ... borrowing a out hat or wide
nter term . For the gala occasions you ' ll be your most fem - inine and appeal
de , taffeta or silk jersey ... If you ' re the talliangorous type , play up yo
 the men . But college social life isn ' t all glamorous J - Hops and Senior Ba
s , Soph Proms and Frosh Frolics ; you ' ll find that your movie or dancing dat
be your choice for these dates . If it ' s a day - time date where you see how 
ong you can dawdle over one coke , you ' ll wear the usual skirt and sweater bi
e description is a " must ",- that you ' ll never be sorry for pair on pair of 
f vivid anklets --- but by now you don ' t need this pony . For by now you ' ve
on ' t need this pony . For by now you ' ve figured out the essence of college 
red out the essence of college clothes ' smartness : dress simply , suit the oc
s simply , suit the occasion , and don ' t dress beyond your means . The girl w
l who blows in with twelve trunks ; it ' s just a matter of selection . 25 If y
just a matter of selection . 25 If you ' re interested in sports , you ' ll fin
If you ' re interested in sports , you ' ll find that W . A . " A ., the Women 
 ll find that W . A . " A ., the Women ' s Athletic Association , will give you
ublications at M . S . C ., and if you ' re interested in writing or photograph
so there is S . W . L ., Spartan Women ' s League , an all - campus organizatio
 interests , and social contacts . Don ' t worry about these before hand , you 
 t worry about these before hand , you ' ll hear worlds about them at the Co - 
charge of the card catalogue and women ' s activity calendar . ARTICLE IV ORGAN
 calendar . ARTICLE IV ORGANIZATION OF ' A . W . S . COUNCIL Section 1 . Member
 of Palenic , President of Spartan men ' s League , President of Y . W . C . A 
ers of the Associated W 0 men Students ' Council shall be made by the preceding
d shall read their reports of the year ' s work . The reports of other cers sha
viduals wishing cooperation from women ' s ganizations . Section 2 . The duties
rmitories , A . W . S . office , women ' s gymnasium and other women ' s buildi
 , women ' s gymnasium and other women ' s buildings ten days before the appoin
tion . 36 1 . Organization : a . Women ' s houses shall have a House Council an
ours : 1 . Mid - week hours : 9 : 45 o ' clock sion until Friday of Fre ::: hma
 place of employment . The Houesmother ' s permission must be obtained in advan
econd time to one student . 4 . Guests ' visiting hours in dormitories and hous
all not go to fraternity houses or men ' s rooms where an proved chaperon is no
 meet with the approval of the student ' s family and that hours are within A .
t of A . W . S ., or the Dean of Women ' s Office . Freshmen must have in addit

In [14]:
len(set(corpus))


Out[14]:
2425

In [15]:
len(corpus)


Out[15]:
17955

In [6]:
corpus.common_contexts(['general'])


and_est s_council have_supervision the_duties

In [21]:
from nltk.corpus import stopwords
stopwords = stopwords.words(english)


  File "<ipython-input-21-644530baa6c1>", line 2
    stopwords = stopwords.words(‘english’)
                                ^
SyntaxError: invalid syntax

In [7]:
corpus.dispersion_plot(["women","girls","fire"])



In [8]:
import mpld3

In [9]:
mpld3.enable_notebook()

In [11]:
corpus.dispersion_plot(["women","girls","fire"], )


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-e36670c73b44> in <module>()
----> 1 corpus.dispersion_plot(["women","girls","fire"], width=1200)

TypeError: dispersion_plot() got an unexpected keyword argument 'width'

In [25]:
len(corpus)


Out[25]:
17955

In [24]:
len(set(corpus)) / len(corpus)


Out[24]:
0

In [26]:
corpus[0:100]


Out[26]:
[u'1937',
 u'-',
 u'1938',
 u'Associated',
 u'Women',
 u'Students',
 u'MICHIGAN',
 u'STATE',
 u'COLLEGE',
 u'A',
 u'.',
 u'W',
 u'.',
 u'S',
 u'.',
 u'\xab\xbb',
 u'REGULATIONS',
 u'FOR',
 u'WOMEN',
 u'\xb7',
 u'STUDENTS',
 u'AT',
 u'MICHIGAN',
 u'STATE',
 u'COLLEGE',
 u'\xab\xbb',
 u'1937',
 u'-',
 u'1938',
 u'Published',
 u'by',
 u'A',
 u'.',
 u'W',
 u'.',
 u'S',
 u'.',
 u'To',
 u'the',
 u'women',
 u'of',
 u'the',
 u'Class',
 u'oj',
 u'1941',
 u'this',
 u'handbook',
 u'is',
 u"'",
 u'dedicated',
 u'by',
 u'the',
 u'Associated',
 u'Women',
 u'Students',
 u'of',
 u'the',
 u'College',
 u'in',
 u'the',
 u'Spirit',
 u'of',
 u'gan',
 u'State',
 u'fellowship',
 u'.',
 u'CODE',
 u'We',
 u',',
 u'the',
 u'women',
 u'students',
 u'of',
 u'Michigan',
 u'State',
 u'College',
 u',',
 u'have',
 u'organized',
 u'ourselves',
 u'into',
 u'an',
 u'association',
 u'and',
 u'have',
 u'voted',
 u'upon',
 u'regulations',
 u'which',
 u'we',
 u'agree',
 u'shall',
 u'be',
 u'ministered',
 u',',
 u'with',
 u'the',
 u'cooperation',
 u'and',
 u'proval']

In [28]:
fdist1 = nltk.FreqDist(corpus)

In [30]:
fdist1.most_common(50)


Out[30]:
[(u'.', 1681),
 (u'the', 693),
 (u'of', 676),
 (u',', 530),
 (u'and', 403),
 (u'to', 292),
 (u'shall', 243),
 (u'be', 225),
 (u'a', 223),
 (u'-', 200),
 (u'A', 195),
 (u'in', 193),
 (u'for', 183),
 (u':', 178),
 (u"'", 152),
 (u'W', 138),
 (u'you', 123),
 (u'The', 121),
 (u'S', 115),
 (u'President', 111),
 (u'Board', 97),
 (u'at', 94),
 (u'or', 92),
 (u'all', 88),
 (u'by', 85),
 (u'have', 82),
 (u'on', 77),
 (u'are', 77),
 (u'term', 75),
 (u'with', 74),
 (u'is', 73),
 (u's', 73),
 (u'Council', 73),
 (u'Women', 72),
 (u'this', 70),
 (u'Judiciary', 65),
 (u'1', 64),
 (u'as', 64),
 (u'one', 62),
 (u'from', 61),
 (u'must', 60),
 (u'your', 59),
 (u'will', 57),
 (u'that', 56),
 (u'hours', 56),
 (u'women', 56),
 (u'"', 55),
 (u'I', 52),
 (u'2', 51),
 (u'week', 51)]

In [31]:
fdist1.plot(50, cumulative=True)



In [ ]:
corpus[w.upper() for w in corpus]