On Fri, 1 Oct 2010, Roman Chyla wrote:
I tried to use the PatternAnalyzer, but am getting NotImplementedError
- in case it is not available, shall I rather use PythonAnalyzer and
implement the regex pattern analyzer with that?
using version: 2.9.3
In [44]: import lucene
In [45]: import pyjama #<-- this package contains java.util.regex.Pattern
In [46]: p = pyjama.Pattern.compile("\\s")
In [47]: p
Out[47]: <Pattern: \s>
In [48]: import lucene.collections as col
In [49]: s = col.JavaSet([])
In [50]: s
Out[50]: <JavaSet: org.apache.pylucene.util.python...@16925b0>
In [51]: pa = lucene.PatternAnalyzer(p,True,s)
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
/Users/rca/<ipython console> in <module>()
NotImplementedError: ('instantiating java class', <type 'PatternAnalyzer'>)
This is because no constructors were generated for PatternAnalyzer. That in
turn is because the java.util.regex package is missing from the JCC command
line in PyLucene's Makefile, causing methods and constructors using classes
in that package to be skipped.
To fix this, add
--package java.util.regex \
around line 214 to PyLucene's Makefile.
It is also strongly recommended that you rebuild pyjama with --import lucene
on the JCC command line so that you don't have JCC generate wrappers
again for classes that are shared between pyjama and lucene.
Andi..