This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
import nltk | |
TOP_PERCENT = .01 | |
def prob_mass_top(counts, n): | |
return sum(count for word, count in counts.most_common(n)) / float(sum(count.values())) | |
count = Counter(word.lower() for word in nltk.corpus.brown.words()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from collections import defaultdict | |
import nltk | |
from nltk.corpus import cmudict | |
def clean_pron(pron): | |
"""Remove stress from pronunciations.""" | |
return re.sub(r"\d", "", pron) |
NewerOlder