Changeset 52847

Show
Ignore:
Timestamp:
05/13/08 14:09:38 (4 months ago)
Author:
bdelbosc
Message:

update to work with latest PyLucene? 2.3.2, credits goes to Gregor Mirai

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/plush/trunk/CHANGES.txt

    r51526 r52847  
    2222:Target: ? 
    2323 
     24New features 
     25~~~~~~~~~~~~ 
     26 
     27* Support PyLucene JCC 2.3.1, this version requires PyLucene JCC version > 2.3.0 
     28  Thanks to Gregor Mirai. 
    2429 
    2530 
  • tools/plush/trunk/README.txt

    r51712 r52847  
    105105* Plush_ requires PyLucene_ which is easy to install using binaries. 
    106106 
    107   Here is an example on how to install the latest PyLucene_ 2.0.0-3 (Lucene_ 
    108   2.0.0-453447) on ubuntu:: 
    109  
    110     cd /tmp 
    111     wget http://downloads.osafoundation.org/PyLucene/linux/ubuntu/PyLucene-2.0.0-3.tar.gz 
    112     tar xzvf PyLucene-2.0.0-3.tar.gz 
    113     cd PyLucene-2.0.0-3/ 
    114     sudo cp -r python/* /usr/lib/python2.4/site-packages/ 
    115     sudo cp -r gcj/* /usr/local/lib 
     107  XXX update with PyLucene 2.3.1 JCC version 
    116108 
    117109  Visit the PyLucene_ site for other pre-built binaries. 
     
    132124    sudo python setup.py install 
    133125 
    134 Thats all no .jar nor java required. 
    135126 
    136127Plush commands 
  • tools/plush/trunk/plush/plush.py

    r51712 r52847  
    3131from cmd import Cmd 
    3232 
    33 from PyLucene import FrenchAnalyzer 
    34 from PyLucene import GermanAnalyzer 
    35 from PyLucene import KeywordAnalyzer 
    36 from PyLucene import SimpleAnalyzer 
    37 from PyLucene import StandardAnalyzer 
    38 from PyLucene import StopAnalyzer 
    39 from PyLucene import WhitespaceAnalyzer 
    40 from PyLucene import QueryParser, IndexSearcher, FSDirectory 
    41 from PyLucene import IndexReader, Sort, JavaError 
    42 from PyLucene import VERSION, LUCENE_VERSION 
    43 from PyLucene import IndexWriter, Field, Document, RAMDirectory 
     33from lucene import FrenchAnalyzer 
     34from lucene import GermanAnalyzer 
     35from lucene import KeywordAnalyzer 
     36from lucene import SimpleAnalyzer 
     37from lucene import StandardAnalyzer 
     38from lucene import StopAnalyzer 
     39from lucene import WhitespaceAnalyzer 
     40from lucene import QueryParser, IndexSearcher, FSDirectory 
     41from lucene import IndexReader, StringReader, Sort, JavaError 
     42from lucene import VERSION 
     43from lucene import Hit 
     44from lucene import IndexWriter, Field, Document, RAMDirectory 
     45 
     46from lucene import initVM, CLASSPATH 
     47initVM(CLASSPATH) 
    4448 
    4549from version import __version__ 
     
    6670        encoding = 'utf-8' 
    6771    return encoding 
    68  
    69 class StringReader(object): 
    70     """Class for analyzer input.""" 
    71     def __init__(self, u_text): 
    72         super(StringReader, self).__init__() 
    73         self.unicodeText = unicode(u_text) 
    74  
    75     def read(self, length=-1): 
    76         """Read.""" 
    77         text = self.unicodeText 
    78         if text is None: 
    79             return u'' 
    80         if length == -1 or length >= len(text): 
    81             self.unicodeText = None 
    82             return text 
    83         text = text[:length] 
    84         self.unicodeText = self.unicodeText[length:] 
    85         return text 
    86  
    87     def close(self): 
    88         """Close""" 
    89         pass 
    9072 
    9173def getTreeSize(top): 
     
    188170        self.store_path = store_path 
    189171        self.index_reader = IndexReader.open(directory) 
    190         self.fields = self.getFieldNames() 
     172        self.fields = [name for name in self.getFieldNames()] 
    191173        self.fields.sort() 
    192174        self._connected = True 
     
    350332 
    351333    intro = """Welcome to Plush %s, a Lucene interactive terminal. 
    352 Using PyLucene %s and Lucene %s. 
     334Using Lucene %s. 
    353335 
    354336  Type: \open [INDEX_PATH]    to open a lucene store 
    355337        \?                    for help 
    356         \q or ^D              to quit.""" % (__version__, 
    357                                              VERSION, LUCENE_VERSION) 
     338        \q or ^D              to quit.""" % (__version__, VERSION) 
    358339    plush_attr = ('limit', 'select', 'default_field', 'sort_on', 
    359340                  'waterline', 'analyzer', 'trunc_size') 
     
    737718        count = 0 
    738719        result_fields = self._getResultFieldIds() 
    739         for i, doc in hits: 
    740             doc_num = hits.id(i) 
     720        for hit in hits: 
     721            hit = Hit.cast_(hit) 
     722            doc = hit.getDocument() 
     723            doc_num = hit.getId() 
    741724            if waterline and doc_num < waterline: 
    742725                continue 
     
    745728                break 
    746729            print "* %2.2d) score: %.2f, doc_num: %s" % (count, hits.score(i), 
    747                                                          hits.id(i)) 
     730                                                         hit.getId()) 
    748731            for field in result_fields: 
    749732                print '  %s: %s' % (field, truncStr(doc.get(field),