2024-09-27 04:22:05 发布
网友
我使用python模式来获取英语名词的单数形式。在
In [1]: from pattern.en import singularize In [2]: singularize('patterns') Out[2]: 'pattern' In [3]: singularize('gases') Out[3]: 'gase'
我在解决第二个问题
有没有更好的方法来做到这一点,例如添加到模式的规则中,或者使exceptionDict在某种程度上成为模式的内部元素?在
exceptionDict
正如评论中所提到的,你最好把单词词组化。 它是nltk stemming module的一部分。在
from nltk.stem import WordNetLemmatizer wnl = WordNetLemmatizer() test_words = ['gases', 'spectrum','cross','nuclei'] %timeit [wnl.lemmatize(wrd) for wrd in test_words] 10000 loops, best of 3: 60.5 µs per loop
与你的功能相比
nltk柠檬化性能更好。在
正如评论中所提到的,你最好把单词词组化。 它是nltk stemming module的一部分。在
与你的功能相比
^{pr2}$nltk柠檬化性能更好。在
相关问题 更多 >
编程相关推荐