[pylucene-dev] Support or not: extension from a Java Lucene
Implementation(Tokenizer or CharTokenizer)
Liang Xing
gorgonking at 163.com
Sun Aug 26 19:22:31 PDT 2007
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osafoundation.org/pipermail/pylucene-dev/attachments/20070827/d17af506/attachment.html
More information about the pylucene-dev
mailing list