【发布时间】:2011-07-02 12:43:42
【问题描述】:
我需要使用 NLTK 找出英语单词中的音节数。这是我到目前为止的代码:
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)
函数调用后,我得到一个名称错误,说算术没有定义。 有人可以帮我找出代码中的错误吗?
【问题讨论】: