【问题标题】:Python stemmer issue: wrong stemPython 词干分析器问题:词干错误
【发布时间】: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 看起来像是computingcomputedcomputercomputation 的词干。就像rotat 似乎对rotaterotation 等很常见。

标签: python words porter-stemmer


【解决方案1】:

引用the page on 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. 所以你的代码很可能会给你正确的结果。你似乎期待一个不是词干分析器产生的引理(除非引理恰好等于词干)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-22
    • 2011-09-05
    • 1970-01-01
    • 1970-01-01
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多