I need to know the number of syllables in a word from English using NLTK. This is the code that I still have:
import curses
from curses.ascii import isdigit
import nltk
from nltk.corpus import cmudict
d = cmudict.dict()
def nsyl(word):
return [len(list(y for y in x if isdigit(y[-1]))) for x in d[word.lower()]]
>>> nsyl(arithmetic)
After calling the function, I get a Name error message saying that arithmetic is not defined. Can someone help me figure out a bug in the code?
source
share