471,342 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,342 software developers and data experts.

Can I extend Java class to my own python implementing class

PyLucene Homepage:
pylucene.osafoundation.org

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 as http://svn.osafoundation.org/pylucen...ordAnalyzer.py
I try a testcase as follows:
Expand|Select|Wrap|Line Numbers
  1. #-------------------tester.py------------------
  2. from PyLucene import StringReader
  3. from PyLucene import CharTokenizer
  4.  
  5. class SimpleKeywordAnalyzer(object):
  6.     def tokenStream(self, fieldName, reader):
  7.         class charTokenizer(object):
  8.             def isTokenChar(self, c):
  9.                 return True
  10.  
  11.         return CharTokenizer(charTokenizer(), reader)
  12.  
  13. if __name__ == '__main__':
  14.     ca = SimpleKeywordAnalyzer()
  15.     strs = ca.tokenStream(' ', StringReader('bonne nuit Francais'))
  16.     print 'Merci'
  17.     for each in strs:
  18.         print each.termText(), each.type()
  19. #-------------------------------------------------------------
Simple as it is, however, it roughly didn't work out.
Expand|Select|Wrap|Line Numbers
  1. Message:
  2. TrackBack:
  3. File 'tester.py', line 21, in <module>
  4.     strs = ca.tokenStream(' ', StringReader('bonne nuit Francais'))
  5. File 'tester.py', line 16, in <module>
  6.     return CharTokenizer(charTokenizer(), reader)
  7. NotImplementedError:('instantiating java class', <type 'PyLuceneCharTokenizer'>
  8.  
-----------------------------------------------
BTW:Environment:
Python 2.5.1,
PyLucene 2.0.0-3,
i686-pc-linux-gnu
Thread model: posix
gcj-3.4.6
Aug 27 '07 #1
0 1171

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Hung Jung Lu | last post: by
9 posts views Thread by F. GEIGER | last post: by
29 posts views Thread by walterbyrd | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.