fnp
/
pylucene.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
old python needs __main__ to call a module
[pylucene.git]
/
samples
/
LuceneInAction
/
lia
/
analysis
/
synonym
/
WordNetSynonymEngine.py
diff --git
a/samples/LuceneInAction/lia/analysis/synonym/WordNetSynonymEngine.py
b/samples/LuceneInAction/lia/analysis/synonym/WordNetSynonymEngine.py
index
9912458
..
8da55b3
100644
(file)
--- a/
samples/LuceneInAction/lia/analysis/synonym/WordNetSynonymEngine.py
+++ b/
samples/LuceneInAction/lia/analysis/synonym/WordNetSynonymEngine.py
@@
-13,22
+13,24
@@
# ====================================================================
from lucene import \
# ====================================================================
from lucene import \
- Document, Term, IndexSearcher, TermQuery, FSDirectory, RAMDirectory, Hit
+ Document, Term, IndexSearcher, TermQuery, \
+ SimpleFSDirectory, RAMDirectory, File
class WordNetSynonymEngine(object):
def __init__(self, indexDir):
class WordNetSynonymEngine(object):
def __init__(self, indexDir):
- self.directory = RAMDirectory(
indexDir
)
+ self.directory = RAMDirectory(
SimpleFSDirectory(File(indexDir))
)
self.searcher = IndexSearcher(self.directory)
def getSynonyms(self, word):
synList = []
self.searcher = IndexSearcher(self.directory)
def getSynonyms(self, word):
synList = []
-
- for hit in self.searcher.search(TermQuery(Term("word", word))):
- doc = Hit.cast_(hit).getDocument()
+ topDocs = self.searcher.search(TermQuery(Term("word", word)), 50)
+
+ for scoreDoc in topDocs.scoreDocs:
+ doc = self.searcher.doc(scoreDoc.doc)
for value in doc.getValues("syn"):
synList.append(value)
for value in doc.getValues("syn"):
synList.append(value)