【问题标题】:Is there a quicker snowball stemmer in python 3.6 than NLTK's?python 3.6 中是否有比 NLTK 更快的雪球词干分析器?
【发布时间】:2018-02-14 14:01:02
【问题描述】:

我目前正在使用 NLTK 的 SnowballStemmer 来阻止我的文档中的单词,当我有 68 个文档时,它运行良好。现在我有 4000 个文档,这太慢了。我读了另一篇文章,有人建议使用PyStemmer,但这在 Python 3.6 上不提供。还有其他软件包可以解决问题吗?或者也许我可以在代码中做一些事情来加快这个过程。

代码:

eng_stemmer = nltk.stem.SnowballStemmer('english')
...
class StemmedCountVectorizer(CountVectorizer):
    def build_analyzer(self):
        analyzer = super(StemmedCountVectorizer, self).build_analyzer()
        return lambda doc: ([eng_stemmer.stem(w) for w in analyzer(doc)])

【问题讨论】:

    标签: python python-3.x nlp nltk stemming


    【解决方案1】:

    PyStemmer 在其文档中并没有说它可以与 python 3.6 一起使用,但它确实可以。安装与 python 3.6 兼容的正确 Visual Studio C++ Build,您可以在此处找到: http://landinghub.visualstudio.com/visual-cpp-build-tools

    然后试试pip install pystemmer

    如果这不起作用,请确保您完全按照此处所述手动安装:https://github.com/snowballstem/pystemmer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多