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/12/02 05:08:28 UTC
svn commit: r1209356 - in /lucene/pylucene/branches/branch_3x: CHANGES
java/org/apache/pylucene/analysis/PythonReusableAnalyzerBase.java
test/test_ReusableAnalyzerBase.py
Author: vajda
Date: Fri Dec 2 04:08:27 2011
New Revision: 1209356
URL: http://svn.apache.org/viewvc?rev=1209356&view=rev
Log:
- fixed bug PYLUCENE-12 (thanks, Mike)
Added:
lucene/pylucene/branches/branch_3x/java/org/apache/pylucene/analysis/PythonReusableAnalyzerBase.java (with props)
lucene/pylucene/branches/branch_3x/test/test_ReusableAnalyzerBase.py (with props)
Modified:
lucene/pylucene/branches/branch_3x/CHANGES
Modified: lucene/pylucene/branches/branch_3x/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/CHANGES?rev=1209356&r1=1209355&r2=1209356&view=diff
==============================================================================
--- lucene/pylucene/branches/branch_3x/CHANGES (original)
+++ lucene/pylucene/branches/branch_3x/CHANGES Fri Dec 2 04:08:27 2011
@@ -1,7 +1,9 @@
-Version 3.4 ->
+Version 3.4 -> 3.5
------------------
+ - using Lucene 3.5 sources
- added facet contrib module to build
- refreshed SynonymAnalyzerViewer sample and wordnet index (Thomas Koch)
+ - added PythonReusableAnalyzerBase (Michael McCandless)
-
Version 3.3 -> 3.4
Added: lucene/pylucene/branches/branch_3x/java/org/apache/pylucene/analysis/PythonReusableAnalyzerBase.java
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/java/org/apache/pylucene/analysis/PythonReusableAnalyzerBase.java?rev=1209356&view=auto
==============================================================================
--- lucene/pylucene/branches/branch_3x/java/org/apache/pylucene/analysis/PythonReusableAnalyzerBase.java (added)
+++ lucene/pylucene/branches/branch_3x/java/org/apache/pylucene/analysis/PythonReusableAnalyzerBase.java Fri Dec 2 04:08:27 2011
@@ -0,0 +1,48 @@
+/* ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.apache.pylucene.analysis;
+
+import org.apache.lucene.analysis.ReusableAnalyzerBase;
+import java.io.Reader;
+
+public class PythonReusableAnalyzerBase extends ReusableAnalyzerBase {
+
+ private long pythonObject;
+
+ public PythonReusableAnalyzerBase()
+ {
+ }
+
+ public void pythonExtension(long pythonObject)
+ {
+ this.pythonObject = pythonObject;
+ }
+ public long pythonExtension()
+ {
+ return this.pythonObject;
+ }
+
+ public void finalize()
+ throws Throwable
+ {
+ pythonDecRef();
+ }
+
+ public native void pythonDecRef();
+
+ @Override
+ public native TokenStreamComponents createComponents(String fieldName, Reader reader);
+}
Propchange: lucene/pylucene/branches/branch_3x/java/org/apache/pylucene/analysis/PythonReusableAnalyzerBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: lucene/pylucene/branches/branch_3x/java/org/apache/pylucene/analysis/PythonReusableAnalyzerBase.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: lucene/pylucene/branches/branch_3x/test/test_ReusableAnalyzerBase.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/branch_3x/test/test_ReusableAnalyzerBase.py?rev=1209356&view=auto
==============================================================================
--- lucene/pylucene/branches/branch_3x/test/test_ReusableAnalyzerBase.py (added)
+++ lucene/pylucene/branches/branch_3x/test/test_ReusableAnalyzerBase.py Fri Dec 2 04:08:27 2011
@@ -0,0 +1,56 @@
+# ====================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+from unittest import TestCase, main
+from lucene import *
+
+
+# Test reusableTokenStream, using ReusableAnalyzerBase:
+class MyAnalyzer(PythonReusableAnalyzerBase):
+
+ def createComponents(self, field, reader):
+ first = LowerCaseTokenizer(Version.LUCENE_CURRENT, reader)
+ last = StopFilter(Version.LUCENE_CURRENT, first, StopAnalyzer.ENGLISH_STOP_WORDS_SET)
+ return ReusableAnalyzerBase.TokenStreamComponents(first, last)
+
+class ReusableAnalyzerBaseTestCase(TestCase):
+
+ def testReusable(self):
+
+ analyzer = MyAnalyzer()
+
+ for method in (analyzer.reusableTokenStream, analyzer.tokenStream):
+ for x in xrange(2):
+ reader = StringReader("This is a test of the english stop analyzer")
+ stream = method("test", reader)
+
+ termAtt = stream.getAttribute(TermAttribute.class_)
+ count = 0
+ while stream.incrementToken():
+ self.assert_(termAtt.term() not in StopAnalyzer.ENGLISH_STOP_WORDS_SET)
+ count += 1
+ self.assertEquals(4, count)
+
+if __name__ == "__main__":
+ import sys, lucene
+ lucene.initVM()
+ if '-loop' in sys.argv:
+ sys.argv.remove('-loop')
+ while True:
+ try:
+ main()
+ except:
+ pass
+ else:
+ main()
Propchange: lucene/pylucene/branches/branch_3x/test/test_ReusableAnalyzerBase.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: lucene/pylucene/branches/branch_3x/test/test_ReusableAnalyzerBase.py
------------------------------------------------------------------------------
svn:mime-type = text/plain