You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-commits@lucene.apache.org by va...@apache.org on 2011/10/27 15:06:21 UTC

svn commit: r1189735 - in /lucene/pylucene/branches/branch_3x: CHANGES Makefile samples/LuceneInAction/indexes.tar.gz samples/LuceneInAction/lia/analysis/synonym/WordNetSynonymEngine.py

Author: vajda
Date: Thu Oct 27 13:06:20 2011
New Revision: 1189735

URL: http://svn.apache.org/viewvc?rev=1189735&view=rev
Log:
 - refreshed SynonymAnalyzerViewer sample and wordnet index (Thomas Koch)

Modified:
    lucene/pylucene/branches/branch_3x/CHANGES
    lucene/pylucene/branches/branch_3x/Makefile
    lucene/pylucene/branches/branch_3x/samples/LuceneInAction/indexes.tar.gz
    lucene/pylucene/branches/branch_3x/samples/LuceneInAction/lia/analysis/synonym/WordNetSynonymEngine.py

Modified: lucene/pylucene/branches/branch_3x/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/CHANGES?rev=1189735&r1=1189734&r2=1189735&view=diff
==============================================================================
--- lucene/pylucene/branches/branch_3x/CHANGES (original)
+++ lucene/pylucene/branches/branch_3x/CHANGES Thu Oct 27 13:06:20 2011
@@ -1,6 +1,7 @@
 Version 3.4 ->
 ------------------
  - added facet contrib module to build
+ - refreshed SynonymAnalyzerViewer sample and wordnet index (Thomas Koch)
  - 
 
 Version 3.3 -> 3.4

Modified: lucene/pylucene/branches/branch_3x/Makefile
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/Makefile?rev=1189735&r1=1189734&r2=1189735&view=diff
==============================================================================
--- lucene/pylucene/branches/branch_3x/Makefile (original)
+++ lucene/pylucene/branches/branch_3x/Makefile Thu Oct 27 13:06:20 2011
@@ -323,7 +323,7 @@ clean:
 
 realclean:
 	if test ! -d $(LUCENE)/.svn; then rm -rf $(LUCENE_SRC); else rm -rf $(LUCENE)/build; fi
-	rm -rf build samples/LuceneInAction/index
+	rm -rf build samples/LuceneInAction/index samples/LuceneInAction/indexes
 
 OS=$(shell uname)
 BUILD_TEST:=$(PYLUCENE)/build/test
@@ -352,6 +352,7 @@ test: install-test samples/LuceneInActio
 	PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/Explainer.py samples/LuceneInAction/index programming
 	PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/HighlightIt.py
 	PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/SortingExample.py
+	PYTHONPATH=$(BUILD_TEST) $(PYTHON) samples/LuceneInAction/SynonymAnalyzerViewer.py
 
 
 ARCHIVE=pylucene-$(VERSION)-src.tar.gz

Modified: lucene/pylucene/branches/branch_3x/samples/LuceneInAction/indexes.tar.gz
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/samples/LuceneInAction/indexes.tar.gz?rev=1189735&r1=1189734&r2=1189735&view=diff
==============================================================================
Binary files - no diff available.

Modified: lucene/pylucene/branches/branch_3x/samples/LuceneInAction/lia/analysis/synonym/WordNetSynonymEngine.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/samples/LuceneInAction/lia/analysis/synonym/WordNetSynonymEngine.py?rev=1189735&r1=1189734&r2=1189735&view=diff
==============================================================================
--- lucene/pylucene/branches/branch_3x/samples/LuceneInAction/lia/analysis/synonym/WordNetSynonymEngine.py (original)
+++ lucene/pylucene/branches/branch_3x/samples/LuceneInAction/lia/analysis/synonym/WordNetSynonymEngine.py Thu Oct 27 13:06:20 2011
@@ -13,22 +13,24 @@
 # ====================================================================
 
 from lucene import \
-     Document, Term, IndexSearcher, TermQuery, FSDirectory, RAMDirectory, Hit
+     Document, Term, IndexSearcher, TermQuery, \
+     SimpleFSDirectory, RAMDirectory, File
 
 
 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 = []
-
-        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)