【发布时间】:2014-10-01 07:49:49
【问题描述】:
您好,我正在尝试使用 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
有什么办法解决这个问题吗?
【问题讨论】:
-
什么词干分析器?您能否提供一个最小、完整且可验证的示例(带有源代码)。
-
嗨,我已经更新了这个问题,这个问题发生在调用词干分析器的行中的两个词干分析器上
-
你想达到什么目的?
-
我正在尝试获取每个单词的词干,例如cats -> cat 或playing -> play
-
为什么
computer -> comput不正确?我可能错了,但comput看起来像是computing、computed、computer、computation的词干。就像rotat似乎对rotate、rotation等很常见。
标签: python words porter-stemmer