Repository navigation
Expand file tree
/
Copy pathvisualize_examples.py
More file actions
55 lines (36 loc) · 1.96 KB
/
Copy pathvisualize_examples.py
File metadata and controls
55 lines (36 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
import _pickle as cPickle
from pythonic_patpho import PatPho
# list of 100 commons nouns from:
# http://stickyball.net/esl-grammar-worksheets.html?id=85
nouns = ['letter', 'number', 'person', 'pen', 'class', 'people', 'sound',
'water', 'side', 'place', 'man', 'men', 'woman', 'women', 'boy',
'girl', 'year', 'day', 'week', 'month', 'name', 'sentence', 'line',
'air', 'land', 'home', 'hand', 'house', 'picture', 'animal',
'mother', 'father', 'brother', 'sister', 'world', 'head', 'page',
'country', 'question', 'answer', 'school', 'plant', 'food', 'sun',
'state', 'eye', 'city', 'tree', 'farm', 'story', 'sea', 'night',
'day', 'life', 'north', 'south', 'east', 'west', 'child',
'children', 'example', 'paper', 'music', 'river', 'car', 'foot',
'feet', 'book', 'science', 'room', 'friend', 'idea', 'fish',
'mountain', 'horse', 'watch', 'colour', 'face', 'wood', 'list',
'bird', 'body', 'dog', 'family', 'song', 'door', 'product', 'wind',
'ship', 'area', 'rock', 'order', 'fire', 'problem', 'piece', 'top',
'bottom', 'king', 'space']
# list of one-syllable rhymes from:
# http://www.rhymer.com/RhymingDictionary/list.html?ref=binfind.com/web
rhymes1 = ['cyst', 'fist', 'gist', 'grist', 'hissed', 'kissed', 'list',
'missed', 'mist', 'tryst', 'twist', 'whist', 'wrist', 'assist']
# list of two-syllable rhymes from:
# http://www.rhymer.com/RhymingDictionary/list.html?ref=binfind.com/web
rhymes2 = ['baptist', 'blacklist', 'consist', 'desist', 'dismissed', 'enlist',
'exist', 'insist', 'persist', 'resist', 'subsist', 'untwist']
pat_pho = PatPho()
mrc_dict = cPickle.load(open(os.getcwd() + '/mrc.p', 'rb'))
vectors = dict()
for word in nouns + rhymes1 + rhymes2:
try:
phonemes = mrc_dict['WTYPE']['n'][word]
except KeyError:
phonemes = mrc_dict['WTYPE']['v'][word]
vectors[word] = pat_pho.get_phon_vector(phonemes)