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:

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.

To me, it almost means that I can't simply extend Java class, in my own Python implementation, such as FunnyTokenizer(PyLucene.CharTokenizer).


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
  5. class SimpleKeywordAnalyzer(object):
  6.     def tokenStream(self, fieldName, reader):
  7.         class charTokenizer(object):
  8.             def isTokenChar(self, c):
  9.                 return True
  11.         return CharTokenizer(charTokenizer(), reader)
  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'>
Python 2.5.1,
PyLucene 2.0.0-3,
Thread model: posix
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.