Hi,

is there any way to use the Java Set class in PyLucene? e.g. the
StopAnalyzer has a constructor with a Set for stopwords:
      StopAnalyzer(Version matchVersion, Set<?> stopWords)
see
http://lucene.apache.org/java/3_5_0/api/all/org/apache/lucene/analysis/StopA
nalyzer.html 

This used to be a list earlier (and worked with Python list of string as
argument), but I fail to pass anything to this constructor (see code below).
I tried to use Python set and lucene.Set as well (cannot be instantiated
though). Did anyone manage to do this yet? Couldn't find examples in the
samples folder either.

(background: I'm currently trying to port some code from PyLucene2.9 to
PyLucene 3.x ...)

Example:

import lucene   
lucene.initVM()
v=lucene.Version.LUCENE_CURRENT 
a= lucene.StopAnalyzer(v)
a.getStopwordSet()
<Set: [but, be, with, such, then, for, no...]> 
s = set(['der','die','das'])# python set
b= lucene.StopAnalyzer(v,s)
   Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   lucene.InvalidArgsError: (<type 'StopAnalyzer'>, '__init__', (<Version:
LUCENE_CURRENT>, set(['die', 'der', 'das'])))

s = lucene.Set(['der','die','das'])
  Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   NotImplementedError: ('instantiating java class', <type 'Set'>)

regards
Thomas
--
Thomas Koch
OrbiTeam Software GmbH & Co. KG
Bonn, Germany
http://www.orbiteam.de






Reply via email to