lucene-pylucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r1759968 - in /lucene/pylucene/trunk/samples: TermPositionVector.py manindex.py mansearch.py
Date Fri, 09 Sep 2016 09:39:05 GMT
Author: vajda
Date: Fri Sep  9 09:39:05 2016
New Revision: 1759968

URL: http://svn.apache.org/viewvc?rev=1759968&view=rev
Log:
got manindex.py mansearch.py and TermPositionVector.py to run

Modified:
    lucene/pylucene/trunk/samples/TermPositionVector.py
    lucene/pylucene/trunk/samples/manindex.py
    lucene/pylucene/trunk/samples/mansearch.py

Modified: lucene/pylucene/trunk/samples/TermPositionVector.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/samples/TermPositionVector.py?rev=1759968&r1=1759967&r2=1759968&view=diff
==============================================================================
--- lucene/pylucene/trunk/samples/TermPositionVector.py (original)
+++ lucene/pylucene/trunk/samples/TermPositionVector.py Fri Sep  9 09:39:05 2016
@@ -5,24 +5,24 @@ from org.apache.lucene.analysis.miscella
 from org.apache.lucene.analysis.standard import StandardAnalyzer
 from org.apache.lucene.store import RAMDirectory
 from org.apache.lucene.document import Document, Field, FieldType
-from org.apache.lucene.util import BytesRef, BytesRefIterator, Version
+from org.apache.lucene.util import BytesRef, BytesRefIterator
 from org.apache.lucene.index import \
-    IndexWriterConfig, IndexWriter, DirectoryReader
+    IndexWriterConfig, IndexWriter, DirectoryReader, IndexOptions
 
 if __name__ == '__main__':
     lucene.initVM(vmargs=['-Djava.awt.headless=true'])
 
 directory = RAMDirectory()
-iconfig = IndexWriterConfig(Version.LUCENE_CURRENT, LimitTokenCountAnalyzer(StandardAnalyzer(Version.LUCENE_CURRENT),
100))
+iconfig = IndexWriterConfig(LimitTokenCountAnalyzer(StandardAnalyzer(), 100))
 iwriter = IndexWriter(directory, iconfig)
 
 ft = FieldType()
-ft.setIndexed(True)
 ft.setStored(True)
 ft.setTokenized(True)
 ft.setStoreTermVectors(True)
 ft.setStoreTermVectorOffsets(True)
 ft.setStoreTermVectorPositions(True)
+ft.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS)
 
 ts = ["this bernhard is the text to be index text",
       "this claudia is the text to be indexed"]
@@ -37,10 +37,10 @@ ireader = DirectoryReader.open(directory
 
 for doc in xrange(0, len(ts)):
     tv = ireader.getTermVector(doc, "fieldname")
-    termsEnum = tv.iterator(None)
+    termsEnum = tv.iterator()
 
     for term in BytesRefIterator.cast_(termsEnum):
-        dpEnum = termsEnum.docsAndPositions(None, None)
+        dpEnum = termsEnum.postings(None)
         dpEnum.nextDoc()  # prime the enum which works only for the current doc
         freq = dpEnum.freq()
 

Modified: lucene/pylucene/trunk/samples/manindex.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/samples/manindex.py?rev=1759968&r1=1759967&r2=1759968&view=diff
==============================================================================
--- lucene/pylucene/trunk/samples/manindex.py (original)
+++ lucene/pylucene/trunk/samples/manindex.py Fri Sep  9 09:39:05 2016
@@ -21,13 +21,12 @@
 import os, re, sys, lucene
 from subprocess import *
 
-from java.io import File
+from java.nio.file import Paths
 from org.apache.lucene.analysis.miscellaneous import LimitTokenCountAnalyzer
 from org.apache.lucene.analysis.standard import StandardAnalyzer
 from org.apache.lucene.index import IndexWriter, IndexWriterConfig
 from org.apache.lucene.document import Document, Field, StringField, TextField
 from org.apache.lucene.store import SimpleFSDirectory
-from org.apache.lucene.util import Version
 
 def indexDirectory(dir):
 
@@ -86,10 +85,10 @@ if __name__ == '__main__':
 
     else:
         lucene.initVM(vmargs=['-Djava.awt.headless=true'])
-        directory = SimpleFSDirectory(File(sys.argv[1]))
-        analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)
+        directory = SimpleFSDirectory(Paths.get(sys.argv[1]))
+        analyzer = StandardAnalyzer()
         analyzer = LimitTokenCountAnalyzer(analyzer, 10000)
-        config = IndexWriterConfig(Version.LUCENE_CURRENT, analyzer)
+        config = IndexWriterConfig(analyzer)
         writer = IndexWriter(directory, config)
 
         manpath = os.environ.get('MANPATH', '/usr/share/man').split(os.pathsep)

Modified: lucene/pylucene/trunk/samples/mansearch.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/samples/mansearch.py?rev=1759968&r1=1759967&r2=1759968&view=diff
==============================================================================
--- lucene/pylucene/trunk/samples/mansearch.py (original)
+++ lucene/pylucene/trunk/samples/mansearch.py Fri Sep  9 09:39:05 2016
@@ -27,13 +27,12 @@ from string import Template
 from datetime import datetime
 from getopt import getopt, GetoptError
 
-from java.io import File
+from java.nio.file import Paths
 from org.apache.lucene.analysis.standard import StandardAnalyzer
 from org.apache.lucene.index import DirectoryReader
 from org.apache.lucene.queryparser.classic import QueryParser
 from org.apache.lucene.search import IndexSearcher
 from org.apache.lucene.store import SimpleFSDirectory
-from org.apache.lucene.util import Version
 
 if __name__ == '__main__':
     lucene.initVM(vmargs=['-Djava.awt.headless=true'])
@@ -66,11 +65,11 @@ class CustomTemplate(Template):
 
 template = CustomTemplate(format)
 
-fsDir = SimpleFSDirectory(File(indexDir))
+fsDir = SimpleFSDirectory(Paths.get(indexDir))
 searcher = IndexSearcher(DirectoryReader.open(fsDir))
 
-analyzer = StandardAnalyzer(Version.LUCENE_CURRENT)
-parser = QueryParser(Version.LUCENE_CURRENT, "keywords", analyzer)
+analyzer = StandardAnalyzer()
+parser = QueryParser("keywords", analyzer)
 parser.setDefaultOperator(QueryParser.Operator.AND)
 query = parser.parse(' '.join(args))
 start = datetime.now()



Mime
View raw message