-1

嗨,我正在尝试使用 python 词干分析器来词干,我尝试了 Porter 和 Lancaster,但他们有同样的问题。他们不能阻止以“er”或“e”结尾的正确单词。

例如,它们茎

computer -->  comput

rotate   -->  rotat

这是代码的一部分

line=line.lower()
line=re.sub(r'[^a-z0-9 ]',' ',line)
line=line.split()
line=[x for x in line if x not in stops]
line=[ porter.stem(word, 0, len(word)-1) for word in line]
# or 'line=[ st.stem(word) for word in line]'
return line

任何想法来解决这个问题?

4

1 回答 1

3

引用Wikipedia 上的页面In computational linguistics, a stem is the part of the word that never changes even when morphologically inflected, whilst a lemma is the base form of the word. For example, given the word "produced", its lemma (linguistics) is "produce", however the stem is "produc": this is because there are words such as production. 因此您的代码可能会给您正确的结果。您似乎期望一个不是词干分析器产生的引理(除非引理恰好等于词干)

于 2014-08-08T00:14:20.083 回答