Skip to content

Instantly share code, notes, and snippets.

@JoFrhwld
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoFrhwld/9b68f9a59e61446a939a to your computer and use it in GitHub Desktop.
Save JoFrhwld/9b68f9a59e61446a939a to your computer and use it in GitHub Desktop.
non initial onset /n/
from nltk.corpus import cmudict
import string
import re
the_dict = cmudict.dict()
the_dict2 = {word: [string.join(x, sep = " ")
for x in entries]
for word, entries in the_dict.items()}
two_n = {word: entries
for word, entries in the_dict2.items()
if any([re.search(r'.+N [AEIOU].*N [AEIOU][^N]+', entry)
for entry in entries])}
print(repr(len(two_n)))
for x in sorted(two_n.keys()):
print("\t" + x)
three_n = {word: entries
for word, entries in the_dict2.items()
if any([re.search(r'.+N [AEIOU].*N [AEIOU].*N [AEIOU][^N]+', entry)
for entry in entries])}
print(repr(len(three_n)))
for x in sorted(three_n.keys()):
print("\t" + x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment