python - 如何在 pylucene 3.5 中实例化 StandardAnalyzer? Version 对象在哪里?

标签 python lucene pylucene

我正在尝试使用 PyLucene,但找不到任何在当前版本中实际运行的代码示例。 (例如,参见http://nullege.com/codes/search/PyLucene.StandardAnalyzer)。

有时您需要实例化分析器。看来这应该通过调用 lucene.StandardAnalyzer() 来完成。但是,这会产生错误:

lucene.InvalidArgsError: (<type 'StandardAnalyzer'>, '__init__', ())

错误的原因非常清楚:StandardAnalyzer 文档,位于 http://lucene.apache.org/core/old_versioned_docs/versions/3_0_3/api/core/index.html ,表示它需要一个 Version 对象的参数。

那么我从哪里获取 Version 对象呢?

以下内容出现在代码示例中,但实际上不起作用:

  • lucene.Version.LUCENE_CURRENT
  • lucene.Version.LUCENE_30

这些名称未定义。这是我的 lucene.Version 类中的内容:

>>> print dir(lucene.Version)
['__class__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_jobject', 'cast_', 'class', 'compareTo', 'declaringClass', 'equals', 'getClass', 'getDeclaringClass', 'hashCode', 'instance_', 'name', 'notify', 'notifyAll', 'of_', 'onOrAfter', 'ordinal', 'parameters_', 'toString', 'valueOf', 'values', 'wait']

最佳答案

如今,PyLucene 版本的 tarball 有一个“samples”目录,其中包含适用于该特定版本的代码。

关于python - 如何在 pylucene 3.5 中实例化 StandardAnalyzer? Version 对象在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10020880/

相关文章:

java - PyLucene 的 Make 和 Make install 出现问题

python - 有没有办法在 Django 中按 View 中的单词截断?

python selenium webdriver 问题(selenium.common.exceptions.WebDriverException : Message: "Can' t load the profile. 配置文件目录:)

java - 我需要使用 Lucene 在调色板上实现图像索引

linux - 如何在 OpenSuSE 或其他基于 rpm 的发行版上安装 PyLucene?

python - pylucene安装makefile报错

python - 多维 ndarray 的 argsort

python - 使用python在json中设置日期时间对象

elasticsearch - Ngram的 Elasticsearch 索引?

elasticsearch - Elasticsearch:使用哪个分析器通过一些特殊字符搜索文档