lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roxana Danger <roxana.dan...@reedonline.co.uk>
Subject accessing to protected elements in PythonTokenizer
Date Fri, 10 Jul 2015 06:59:58 GMT
Hello,
       I am trying to construct a custom PythonTokenizer (see above), but I
am getting the error: "attribute 'reader' of 'Tokenizer' objects is not
readable" when accessing to it in reset class.
       reader is a protected member in Tokenizer, I was supposing it to be
exposed through PythonTokenizer, and it is passed to the super class in the
constructor. Am I wrong?
       Thanks, best regards,
             Roxana

class ComposerTokenizer(PythonTokenizer):

     def __init__(self, input):

           PythonTokenizer.__init__(self, input)

           self.reset()



     def incrementToken(self):

          if self.index < len(self.finaltokens):

                self.clearAttributes()

                offsetAttr = OffsetAttributeImpl()

                offsetAttr.setOffset( ... )

                self.index = self.index + 1

                return True

            else:

                 return False


       def reset(self):

             s = ''

             ch = self.reader.read()

             while ch <> -1:

                   s = s + ch

                   ch = self.reader.read()

             self.index = 0

             self.finalTokens = ... #processing s to extract
self.finaltokens









<http://www.reed.co.uk/lovemondays>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message