In [1]:
import nltk
In [2]:
from urllib.request import urlopen
my_url = "http://gutenberg.net.au/ebooks02/0200331.txt"
file = urlopen(my_url)
raw = file.read()
orlando = raw.decode()
o_tokens = nltk.word_tokenize(orlando)
In [3]:
o_text = o_tokens[872:-5]
In [4]:
orl = nltk.Text(o_text)
orl
Out[4]:
<Text: He -- for there could be no doubt...>

cleaning the text (caps, punct, stops)

In [5]:
orl[:41]
Out[5]:
['He',
 '--',
 'for',
 'there',
 'could',
 'be',
 'no',
 'doubt',
 'of',
 'his',
 'sex',
 ',',
 'though',
 'the',
 'fashion',
 'of',
 'the',
 'time',
 'did',
 'something',
 'to',
 'disguise',
 'it',
 '--',
 'was',
 'in',
 'the',
 'act',
 'of',
 'slicing',
 'at',
 'the',
 'head',
 'of',
 'a',
 'Moor',
 'which',
 'swung',
 'from',
 'the',
 'rafters']
In [6]:
# lowercasing and removing punct
lower_no_punct = []
for word in orl:
    if word.isalpha():
        lower_no_punct.append(word.lower())
In [7]:
from nltk.corpus import stopwords
stops = stopwords.words('english')
# removing stops
no_stops = [word for word in lower_no_punct if word not in stops]
In [8]:
no_stops[:10]
Out[8]:
['could',
 'doubt',
 'sex',
 'though',
 'fashion',
 'time',
 'something',
 'disguise',
 'act',
 'slicing']
In [9]:
# lemmatizing
from nltk.stem import WordNetLemmatizer
wordnet_lemmatizer = WordNetLemmatizer()
clean_text = []
for word in no_stops:
    word_lem = wordnet_lemmatizer.lemmatize(word)
    clean_text.append(word_lem)
    
clean_text[:30]
Out[9]:
['could',
 'doubt',
 'sex',
 'though',
 'fashion',
 'time',
 'something',
 'disguise',
 'act',
 'slicing',
 'head',
 'moor',
 'swung',
 'rafter',
 'colour',
 'old',
 'football',
 'le',
 'shape',
 'one',
 'save',
 'sunken',
 'cheek',
 'strand',
 'two',
 'coarse',
 'dry',
 'hair',
 'like',
 'hair']
In [10]:
orl = clean_text

similar words, first level

to compute distinctive similarity, we:

  • make a list of words similar to "man" or "woman" using Text.similar()
  • find words similar to those words
  • filter out the words that are shared among the two lists
  • repeat as needed
In [11]:
# to make these lists of distictive similar words automatically, 
# use ContextIndex class
idx = nltk.text.ContextIndex(orl)
# put words similar to woman in a list
woman_sim_1 = idx.similar_words("woman")
woman_sim_1_str = " ".join(woman_sim_1)
woman_sim_1_str
Out[11]:
'reached till friend word moment saw always could cried sailor wit scarcely petticoat go servant conclusion'
In [12]:
# put words similar to man in a list
man_sim_1 = idx.similar_words("man")
man_sim_1
man_sim_1_str = " ".join(man_sim_1)
man_sim_1_str
Out[12]:
'hurry father window tongue carriage still even countrywoman indulged old fortune title ship writing fell become always love grown never'
In [13]:
# loops through woman similar and filters out words shared with man similar
woman_disc_1 = []
for word in woman_sim_1:
    if word not in man_sim_1:
        woman_disc_1.append(word)
woman_disc_1
Out[13]:
['reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion']
In [14]:
# loops through man similar and filters out words shared with woman similar
man_disc_1 = []
for word in man_sim_1:
    if word not in woman_sim_1:
        man_disc_1.append(word)
man_disc_1
Out[14]:
['hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'love',
 'grown',
 'never']

similar words, second level

In [15]:
# loop that computes similar words for each word from woman_sim_1
woman_sim_2_nested = []
for word in woman_disc_1:
    woman_sim_2_nested.append(idx.similar_words(word)) # this returns nested lists

# list comprehension that flattens nested list
woman_sim_2 = [inner
    for outer in woman_sim_2_nested
        for inner in outer]

# create a string that joins all words
woman_sim_2_str =" ".join(set(woman_sim_2))
woman_sim_2_str
Out[15]:
'window fly scarcely able understood prophet could shape reached explain toss indeed say encumbrance bird rust make another thought fool time wit met woman year always come laughing roused friend stood word allied none known sailor sake happiness dog would mixture till used cried leave thing ran might petticoat way london account madam first wisdom'
In [16]:
len(set(woman_sim_2))
Out[16]:
55
In [17]:
# creating a loop to find similar words to man_sim_1
man_sim_2_nested = []
for word in man_sim_1:
    man_sim_2_nested.append(idx.similar_words(word))
man_sim_2_nested

# collapsing the nested list
man_sim_2 = [inner
    for outer in man_sim_2_nested
        for inner in outer]

man_sim_2_str =" ".join(set(man_sim_2))
man_sim_2_str
Out[17]:
'window exactly grown monstrously take still fault beautiful orlando alone sink morning determined plump without strength passion love gloomy man two woman always little perhaps carriage roused come hurry moment matter whose word must death admit boy title hungry would old hear fortune almost father saw written kinsman need tongue full sens ever become soon'
In [18]:
# loops through woman similar and filters out words shared with man similar
woman_disc_2 = []
for word in woman_sim_2:
    if word not in man_sim_2:
        woman_disc_2.append(word)
woman_disc_2
Out[18]:
['till',
 'reached',
 'friend',
 'time',
 'dog',
 'explain',
 'thing',
 'another',
 'mixture',
 'toss',
 'way',
 'first',
 'met',
 'madam',
 'stood',
 'might',
 'used',
 'understood',
 'prophet',
 'bird',
 'thought',
 'shape',
 'none',
 'cried',
 'allied',
 'known',
 'laughing',
 'fool',
 'london',
 'could',
 'ran',
 'wit',
 'able',
 'happiness',
 'wisdom',
 'sailor',
 'say',
 'petticoat',
 'indeed',
 'scarcely',
 'encumbrance',
 'account',
 'fly',
 'leave',
 'rust',
 'make',
 'sake',
 'year']
In [19]:
len(set(woman_disc_2))
Out[19]:
48
In [20]:
# loops through woman similar and filters out words shared with man similar
man_disc_2 = []
for word in man_sim_2:
    if word not in woman_sim_2:
        man_disc_2.append(word)
man_disc_2
Out[20]:
['man',
 'father',
 'tongue',
 'carriage',
 'still',
 'man',
 'written',
 'fault',
 'hurry',
 'tongue',
 'carriage',
 'still',
 'man',
 'old',
 'hurry',
 'father',
 'tongue',
 'carriage',
 'still',
 'strength',
 'moment',
 'man',
 'hurry',
 'father',
 'carriage',
 'still',
 'man',
 'hurry',
 'father',
 'tongue',
 'still',
 'man',
 'need',
 'hungry',
 'beautiful',
 'monstrously',
 'hear',
 'without',
 'hurry',
 'father',
 'tongue',
 'carriage',
 'full',
 'two',
 'determined',
 'morning',
 'man',
 'matter',
 'man',
 'man',
 'strength',
 'man',
 'must',
 'plump',
 'sens',
 'morning',
 'man',
 'title',
 'man',
 'fortune',
 'man',
 'whose',
 'passion',
 'boy',
 'little',
 'man',
 'sink',
 'man',
 'love',
 'man',
 'grown',
 'become',
 'love',
 'man',
 'grown',
 'saw',
 'take',
 'kinsman',
 'perhaps',
 'soon',
 'become',
 'man',
 'grown',
 'exactly',
 'become',
 'love',
 'man',
 'alone',
 'gloomy',
 'almost',
 'death',
 'man',
 'ever',
 'orlando',
 'admit']
In [21]:
woman_disc_2_str = ' '.join(set(woman_disc_2))
woman_disc_2_str
Out[21]:
'fly scarcely able understood prophet could shape reached explain toss indeed say encumbrance bird rust make another thought fool time wit met year laughing stood friend known allied none sailor sake happiness dog mixture till used cried leave thing ran might petticoat way london account madam first wisdom'
In [22]:
man_disc_2_str = ' '.join(set(man_disc_2))
man_disc_2_str
Out[22]:
'exactly grown monstrously take still fault beautiful orlando alone sink morning determined plump without strength passion love gloomy man two little perhaps carriage hurry moment matter whose admit must death boy title hungry old hear fortune almost father saw written kinsman need tongue full sens ever become soon'

Third Level

In [23]:
# 3rd level words similar to woman_disc_2
woman_sim_3_nested = []
for word in woman_sim_2:
    woman_sim_3_nested.append(idx.similar_words(word)) # this returns nested lists

# list comprehension that flattens nested list
woman_sim_3 = [inner
    for outer in woman_sim_3_nested
        for inner in outer]

woman_sim_3
Out[23]:
['reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'woman',
 'reached',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'woman',
 'till',
 'friend',
 'woman',
 'time',
 'dog',
 'window',
 'roused',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'word',
 'woman',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'went',
 'top',
 'gave',
 'word',
 'green',
 'character',
 'thought',
 'ribbon',
 'would',
 'finger',
 'draw',
 'true',
 'side',
 'visit',
 'way',
 'street',
 'must',
 'sex',
 'insipid',
 'thing',
 'good',
 'word',
 'man',
 'old',
 'roused',
 'word',
 'hurry',
 'father',
 'tongue',
 'carriage',
 'still',
 'strength',
 'moment',
 'passed',
 'window',
 'word',
 'moment',
 'since',
 'sawings',
 'moment',
 'another',
 'among',
 'dog',
 'must',
 'sex',
 'insipid',
 'person',
 'moment',
 'thing',
 'life',
 'people',
 'moment',
 'moment',
 'sag',
 'top',
 'ring',
 'knee',
 'moment',
 'draw',
 'true',
 'side',
 'visit',
 'street',
 'time',
 'man',
 'old',
 'roused',
 'word',
 'hurry',
 'father',
 'tongue',
 'carriage',
 'still',
 'strength',
 'moment',
 'moment',
 'frequent',
 'life',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'become',
 'love',
 'man',
 'grown',
 'saw',
 'woman',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'fasten',
 'raising',
 'saw',
 'seen',
 'saw',
 'standing',
 'bald',
 'alone',
 'launched',
 'burst',
 'gently',
 'flung',
 'saw',
 'could',
 'used',
 'course',
 'let',
 'suddenly',
 'could',
 'might',
 'would',
 'could',
 'thought',
 'spoke',
 'may',
 'contrived',
 'could',
 'bird',
 'could',
 'prophet',
 'none',
 'understood',
 'say',
 'hot',
 'looked',
 'could',
 'third',
 'time',
 'heard',
 'shut',
 'sat',
 'gazing',
 'marvel',
 'felt',
 'occupation',
 'say',
 'search',
 'could',
 'came',
 'never',
 'waited',
 'voyage',
 'omit',
 'could',
 'thought',
 'try',
 'could',
 'contrived',
 'understood',
 'next',
 'seen',
 'planned',
 'greene',
 'list',
 'embrace',
 'ancestor',
 'could',
 'never',
 'orlando',
 'must',
 'time',
 'great',
 'sight',
 'favilla',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'london',
 'woman',
 'could',
 'ran',
 'could',
 'prayer',
 'could',
 'hid',
 'could',
 'could',
 'cried',
 'beneath',
 'new',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'might',
 'used',
 'understood',
 'prophet',
 'bird',
 'thought',
 'come',
 'shape',
 'none',
 'would',
 'woman',
 'cried',
 'allied',
 'known',
 'laughing',
 'fool',
 'cried',
 'went',
 'passed',
 'ala',
 'reflection',
 'catching',
 'able',
 'happiness',
 'wisdom',
 'sailor',
 'woman',
 'say',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'wit',
 'wit',
 'wit',
 'one',
 'wit',
 'woman',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'ask',
 'bethink',
 'blackness',
 'found',
 'scramble',
 'going',
 'thought',
 'wit',
 'come',
 'denied',
 'leave',
 'observed',
 'groping',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'scarcely',
 'woman',
 'minute',
 'day',
 'scarcely',
 'woman',
 'petticoat',
 'indeed',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'go',
 'go',
 'case',
 'leave',
 'rust',
 'go',
 'summer',
 'slept',
 'upstairs',
 'say',
 'fly',
 'rust',
 'go',
 'fly',
 'leave',
 'go',
 'go',
 'profit',
 'slipping',
 'go',
 'one',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'month',
 'came',
 'bred',
 'thousand',
 'nail',
 'child',
 'servant',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion']
In [24]:
# 3rd level words similar to man_disc_2
man_sim_3_nested = []
for word in man_sim_2:
    man_sim_3_nested.append(idx.similar_words(word)) # this returns nested lists

# list comprehension that flattens nested list
man_sim_3 = [inner
    for outer in man_sim_3_nested
        for inner in outer]

man_sim_3
Out[24]:
['hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'man',
 'written',
 'fault',
 'hurry',
 'window',
 'tongue',
 'carriage',
 'still',
 'man',
 'old',
 'roused',
 'word',
 'hurry',
 'father',
 'tongue',
 'carriage',
 'still',
 'strength',
 'moment',
 'man',
 'hurry',
 'father',
 'window',
 'carriage',
 'still',
 'man',
 'hurry',
 'father',
 'window',
 'tongue',
 'still',
 'man',
 'need',
 'hungry',
 'beautiful',
 'monstrously',
 'hear',
 'without',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'father',
 'fault',
 'remembered',
 'father',
 'written',
 'man',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'man',
 'old',
 'roused',
 'word',
 'hurry',
 'father',
 'tongue',
 'carriage',
 'still',
 'strength',
 'moment',
 'man',
 'hurry',
 'father',
 'window',
 'carriage',
 'still',
 'man',
 'hurry',
 'father',
 'window',
 'tongue',
 'still',
 'man',
 'need',
 'hungry',
 'beautiful',
 'monstrously',
 'hear',
 'without',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'strength',
 'window',
 'man',
 'must',
 'plump',
 'passed',
 'window',
 'word',
 'friend',
 'woman',
 'time',
 'dog',
 'window',
 'roused',
 'man',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'man',
 'written',
 'fault',
 'hurry',
 'window',
 'tongue',
 'carriage',
 'still',
 'man',
 'hurry',
 'father',
 'window',
 'carriage',
 'still',
 'man',
 'hurry',
 'father',
 'window',
 'tongue',
 'still',
 'man',
 'need',
 'hungry',
 'beautiful',
 'monstrously',
 'hear',
 'without',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'old',
 'window',
 'explain',
 'thing',
 'another',
 'mixture',
 'toss',
 'way',
 'window',
 'first',
 'woman',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'man',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'man',
 'written',
 'fault',
 'hurry',
 'window',
 'tongue',
 'carriage',
 'still',
 'man',
 'old',
 'roused',
 'word',
 'hurry',
 'father',
 'tongue',
 'carriage',
 'still',
 'strength',
 'moment',
 'man',
 'hurry',
 'father',
 'window',
 'tongue',
 'still',
 'man',
 'need',
 'hungry',
 'beautiful',
 'monstrously',
 'hear',
 'without',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'man',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'man',
 'written',
 'fault',
 'hurry',
 'window',
 'tongue',
 'carriage',
 'still',
 'man',
 'old',
 'roused',
 'word',
 'hurry',
 'father',
 'tongue',
 'carriage',
 'still',
 'strength',
 'moment',
 'man',
 'hurry',
 'father',
 'window',
 'carriage',
 'still',
 'man',
 'need',
 'hungry',
 'beautiful',
 'monstrously',
 'hear',
 'without',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'still',
 'hungry',
 'need',
 'still',
 'still',
 'still',
 'still',
 'imagine',
 'still',
 'pared',
 'long',
 'one',
 'man',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'man',
 'written',
 'fault',
 'hurry',
 'window',
 'tongue',
 'carriage',
 'still',
 'man',
 'old',
 'roused',
 'word',
 'hurry',
 'father',
 'tongue',
 'carriage',
 'still',
 'strength',
 'moment',
 'man',
 'hurry',
 'father',
 'window',
 'carriage',
 'still',
 'man',
 'hurry',
 'father',
 'window',
 'tongue',
 'still',
 'even',
 'set',
 'whole',
 'filled',
 'raised',
 'needing',
 'rout',
 'even',
 'agitate',
 'awkwardness',
 'talk',
 'even',
 'even',
 'story',
 'fortune',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'even',
 'man',
 'sex',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'old',
 'window',
 'man',
 'old',
 'roused',
 'word',
 'hurry',
 'father',
 'tongue',
 'carriage',
 'still',
 'strength',
 'moment',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'old',
 'admitted',
 'orlando',
 'dog',
 'sex',
 'insipid',
 'thing',
 'many',
 'would',
 'certain',
 'longed',
 'husband',
 'old',
 'fortune',
 'even',
 'story',
 'fortune',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'man',
 'fortune',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'sens',
 'morning',
 'man',
 'title',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'writing',
 'passion',
 'writing',
 'whose',
 'man',
 'writing',
 'wicket',
 'iron',
 'writing',
 'taste',
 'mind',
 'made',
 'profound',
 'deep',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'fell',
 'put',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'become',
 'love',
 'man',
 'grown',
 'saw',
 'woman',
 'take',
 'kinsman',
 'perhaps',
 'soon',
 'become',
 'always',
 'man',
 'grown',
 'exactly',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'become',
 'always',
 'love',
 'man',
 'alone',
 'always',
 'love',
 'man',
 'grown',
 'take',
 'kinsman',
 'perhaps',
 'soon',
 'become',
 'always',
 'man',
 'grown',
 'exactly',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'become',
 'always',
 'love',
 'man',
 'alone',
 'always',
 'woman',
 'met',
 'madam',
 'stood',
 'reached',
 'till',
 'friend',
 'word',
 'moment',
 'saw',
 'always',
 'could',
 'cried',
 'sailor',
 'wit',
 'scarcely',
 'petticoat',
 'go',
 'servant',
 'conclusion',
 'turn',
 'made',
 'love',
 'love',
 'perhaps',
 'fumbled',
 'tell',
 'pushing',
 'kinsman',
 'love',
 'love',
 'always',
 'love',
 'man',
 'grown',
 'become',
 'love',
 'man',
 'grown',
 'saw',
 'woman',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'become',
 'always',
 'love',
 'man',
 'alone',
 'love',
 'always',
 'love',
 'man',
 'grown',
 'become',
 'love',
 'man',
 'grown',
 'saw',
 'woman',
 'take',
 'kinsman',
 'perhaps',
 'soon',
 'become',
 'always',
 'man',
 'grown',
 'exactly',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'whatever',
 'stood',
 'grown',
 'glance',
 'never',
 'immovable',
 'never',
 'treachery',
 'visit',
 'inborn',
 'never',
 'man',
 'hurry',
 'father',
 'window',
 'tongue',
 'carriage',
 'still',
 'even',
 'countrywoman',
 'indulged',
 'old',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'become',
 'always',
 'love',
 'grown',
 'never',
 'sleep',
 'never',
 'contrived',
 'understood',
 'next',
 'seen',
 'planned',
 'greene',
 'list',
 'embrace',
 'ancestor',
 'could',
 'never',
 'orlando',
 'must',
 'time',
 'great',
 'sight',
 'favilla',
 'shut',
 'sat',
 'gazing',
 'marvel',
 'felt',
 'occupation',
 'say',
 'search',
 'could',
 'came',
 'never',
 'waited',
 'part',
 'boyish',
 'beard',
 'insisted',
 'blush',
 'looking',
 'said',
 'passed',
 'princess',
 'life',
 'circle',
 'ague',
 'longer',
 'would',
 'round',
 'tied',
 'never',
 'course',
 'must',
 'beast',
 'sofa',
 'never']
In [25]:
# loops through woman similar and filters out words shared with man similar
woman_disc_3 = []
for word in woman_sim_3:
    if word not in man_sim_3:
        woman_disc_3.append(word)
woman_disc_3
Out[25]:
['went',
 'top',
 'gave',
 'green',
 'character',
 'thought',
 'ribbon',
 'finger',
 'draw',
 'true',
 'side',
 'street',
 'good',
 'since',
 'sawings',
 'among',
 'person',
 'people',
 'sag',
 'top',
 'ring',
 'knee',
 'draw',
 'true',
 'side',
 'street',
 'frequent',
 'fasten',
 'raising',
 'standing',
 'bald',
 'launched',
 'burst',
 'gently',
 'flung',
 'used',
 'let',
 'suddenly',
 'might',
 'thought',
 'spoke',
 'may',
 'bird',
 'prophet',
 'none',
 'hot',
 'looked',
 'third',
 'heard',
 'voyage',
 'omit',
 'thought',
 'try',
 'london',
 'ran',
 'prayer',
 'hid',
 'beneath',
 'new',
 'might',
 'used',
 'prophet',
 'bird',
 'thought',
 'come',
 'shape',
 'none',
 'allied',
 'known',
 'laughing',
 'fool',
 'went',
 'ala',
 'reflection',
 'catching',
 'able',
 'happiness',
 'wisdom',
 'ask',
 'bethink',
 'blackness',
 'found',
 'scramble',
 'going',
 'thought',
 'come',
 'denied',
 'leave',
 'observed',
 'groping',
 'minute',
 'day',
 'indeed',
 'case',
 'leave',
 'rust',
 'summer',
 'slept',
 'upstairs',
 'fly',
 'rust',
 'fly',
 'leave',
 'profit',
 'slipping',
 'month',
 'bred',
 'thousand',
 'nail',
 'child']
In [26]:
# loops through woman similar and filters out words shared with man similar
man_disc_3 = []
for word in man_sim_3:
    if word not in woman_sim_3:
        man_disc_3.append(word)
man_disc_3
Out[26]:
['even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'written',
 'fault',
 'need',
 'hungry',
 'beautiful',
 'monstrously',
 'hear',
 'without',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'fault',
 'remembered',
 'written',
 'need',
 'hungry',
 'beautiful',
 'monstrously',
 'hear',
 'without',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'plump',
 'written',
 'fault',
 'need',
 'hungry',
 'beautiful',
 'monstrously',
 'hear',
 'without',
 'explain',
 'mixture',
 'toss',
 'first',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'written',
 'fault',
 'need',
 'hungry',
 'beautiful',
 'monstrously',
 'hear',
 'without',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'written',
 'fault',
 'need',
 'hungry',
 'beautiful',
 'monstrously',
 'hear',
 'without',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'hungry',
 'need',
 'imagine',
 'pared',
 'long',
 'written',
 'fault',
 'even',
 'set',
 'whole',
 'filled',
 'raised',
 'needing',
 'rout',
 'even',
 'agitate',
 'awkwardness',
 'talk',
 'even',
 'even',
 'story',
 'fortune',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'even',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'admitted',
 'many',
 'certain',
 'longed',
 'husband',
 'fortune',
 'even',
 'story',
 'fortune',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'fortune',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'sens',
 'morning',
 'title',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'writing',
 'passion',
 'writing',
 'whose',
 'writing',
 'wicket',
 'iron',
 'writing',
 'taste',
 'mind',
 'made',
 'profound',
 'deep',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'fell',
 'put',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'take',
 'kinsman',
 'perhaps',
 'soon',
 'exactly',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'take',
 'kinsman',
 'perhaps',
 'soon',
 'exactly',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'met',
 'madam',
 'stood',
 'turn',
 'made',
 'perhaps',
 'fumbled',
 'tell',
 'pushing',
 'kinsman',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'take',
 'kinsman',
 'perhaps',
 'soon',
 'exactly',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'whatever',
 'stood',
 'glance',
 'immovable',
 'treachery',
 'inborn',
 'even',
 'countrywoman',
 'indulged',
 'fortune',
 'title',
 'ship',
 'writing',
 'fell',
 'sleep',
 'part',
 'boyish',
 'beard',
 'insisted',
 'blush',
 'looking',
 'said',
 'princess',
 'circle',
 'ague',
 'longer',
 'round',
 'tied',
 'beast',
 'sofa']
In [27]:
set(woman_disc_3)
Out[27]:
{'able',
 'ala',
 'allied',
 'among',
 'ask',
 'bald',
 'beneath',
 'bethink',
 'bird',
 'blackness',
 'bred',
 'burst',
 'case',
 'catching',
 'character',
 'child',
 'come',
 'day',
 'denied',
 'draw',
 'fasten',
 'finger',
 'flung',
 'fly',
 'fool',
 'found',
 'frequent',
 'gave',
 'gently',
 'going',
 'good',
 'green',
 'groping',
 'happiness',
 'heard',
 'hid',
 'hot',
 'indeed',
 'knee',
 'known',
 'laughing',
 'launched',
 'leave',
 'let',
 'london',
 'looked',
 'may',
 'might',
 'minute',
 'month',
 'nail',
 'new',
 'none',
 'observed',
 'omit',
 'people',
 'person',
 'prayer',
 'profit',
 'prophet',
 'raising',
 'ran',
 'reflection',
 'ribbon',
 'ring',
 'rust',
 'sag',
 'sawings',
 'scramble',
 'shape',
 'side',
 'since',
 'slept',
 'slipping',
 'spoke',
 'standing',
 'street',
 'suddenly',
 'summer',
 'third',
 'thought',
 'thousand',
 'top',
 'true',
 'try',
 'upstairs',
 'used',
 'voyage',
 'went',
 'wisdom'}
In [28]:
woman_disc3_str = " ".join(set(woman_disc_3))
woman_disc3_str
Out[28]:
'hid prophet upstairs suddenly finger shape bred case thought going since spoke voyage fool try allied none omit true profit summer person people hot fasten wisdom fly may indeed side day catching laughing ask found let ala raising flung used leave month thousand gently new child launched observed slept able ring minute third burst known happiness looked bald slipping sag gave nail knee green bird rust blackness street good character draw sawings prayer ribbon come went groping among frequent beneath standing ran denied might heard top reflection london bethink scramble'
In [29]:
man_disc3_str = " ".join(set(man_disc_3))
man_disc3_str
Out[29]:
'iron princess take fault morning plump ague rout certain passion put met stood turn made mixture profound writing need madam said looking longed explain mind without imagine admitted wicket blush long perhaps whose hungry whole remembered boyish even kinsman soon exactly monstrously husband longer indulged countrywoman fell toss insisted filled circle talk pushing glance part taste beast title agitate sofa tell hear needing pared tied many first sens round awkwardness sleep beautiful fumbled ship deep immovable story raised beard whatever fortune written inborn set treachery'
In [ ]:
 
In [ ]: