Last active
December 17, 2019 20:14
-
-
Save glickmac/33e81c2e1810afa98c13c302757d36dc to your computer and use it in GitHub Desktop.
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
text = text.translate(str.maketrans('', '', string.punctuation)) | |
animals = {"polynesia":"parrot", "gubgub":"pig", "cheechee":"monkey", "tootoo":"owl","pushmipullyu":"two-headed unicorn", "whitey":"mouse", "jip":"dog", "dabdab":"duck", "toggle":"horse", "cheapside":"sparrow"} | |
text = ' '.join([animals.get(i, i) for i in text.split()]) | |
with open("../data/Animal_Names.txt", "r") as f: | |
animals = f.readlines() | |
animals = [x.split("\n")[0] for x in animals] | |
Animals_in_Text = set(animals) & set(tokens) | |
print("Doctor Dolittle interacts with " + str(len(Animals_in_Text)) + " different kinds of animals") | |
values = [i for i in values if i in Animals_in_Text] | |
freq = nltk.FreqDist(values) | |
freq.plot(25, cumulative=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment