[pylucene-dev] Support or not: extension from a Java Lucene Implementation(Tokenizer or CharTokenizer)

Andi Vajda vajda at osafoundation.org
Sun Aug 26 19:46:51 PDT 2007



On Mon, 27 Aug 2007, Liang Xing wrote:

> 1.Quotas from PyLucene: """Technically, the PyLucene programmer is not providing an 'extension'
> but a Python implementation of a set of methods encapsulated by a
> Python class whose instances are wrapped by the Java proxies provided
> by PyLucene.       ----http://svn.nuxeo.org/pub/vendor/PyLucene/tags/1.9rc1-1/README """To me, it almost means that I can't simply extend Java class, in my own Python implementation, such as FunnyTokenizer(PyLucene.CharTokenizer). 2.Testcase Thanks to the link offered ashttp://svn.osafoundation.org/pylucene/trunk/samples/LuceneInAction/lia/analysis/keyword/SimpleKeywordAnalyzer.pyI try a testcase as follows: #-------------------tester.py------------------from PyLucene import StringReaderfrom PyLucene import CharTokenizer class SimpleKeywordAnalyzer(object):    def tokenStream(self, fieldName, reader):        class charTokenizer(object):            def isTokenChar(self, c):
>                return True
>
>        return CharTokenizer(charTokenizer(), reader) if __name__ == '__main__':    ca = SimpleKeywordAnalyzer()    strs = ca.tokenStream(' ', StringReader('bonne nuit Francais'))    print 'Merci'    for each in strs:        print each.termText(), each.type()#------------------------------------------------------------- Simple as it is, however, it roughly didn't work out.Message:TrackBack:File 'tester.py', line 21, in <module>    strs = ca.tokenStream(' ', StringReader('bonne nuit Francais'))File 'tester.py', line 16, in <module>    return CharTokenizer(charTokenizer(), reader)NotImplementedError:('instantiating java class', <type 'PyLuceneCharTokenizer'> -----------------------------------------------BTW:Environment:Python 2.5.1,PyLucene 2.0.0-3,i686-pc-linux-gnuThread model: posixgcj-3.4.6

It works fine for me. Please provide more information. What are version are
you running ? What operating system ? etc...

     yuzu:vajda> python samples/LuceneInAction/KeywordAnalyzerTest.py
     ....
     ----------------------------------------------------------------------
     Ran 4 tests in 0.006s

     OK


Andi..


More information about the pylucene-dev mailing list