Skip to content

Instantly share code, notes, and snippets.

@amundo
Last active January 4, 2016 13:09
Show Gist options
  • Select an option

  • Save amundo/8626002 to your computer and use it in GitHub Desktop.

Select an option

Save amundo/8626002 to your computer and use it in GitHub Desktop.
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