Last active
January 4, 2016 13:09
-
-
Save amundo/8626002 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 matplotlib.pyplot as plt | |
| import numpy as np | |
| from nltk.corpus import inaugural | |
| def count_vowels(word): | |
| return len([c for c in word.lower() if c in 'aeiou']) | |
| words = set(inaugural.words()) | |
| lengths = [len(w) for w in words] | |
| vowel_count = [count_vowels(w) for w in words] | |
| plt.ylabel('number of vowels per word') | |
| plt.xlabel('length of word') | |
| plt.scatter(lengths, vowel_count) | |
| plt.title('vowel count as a function of word length') | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment