It looks to me as if, when I obtain a DefaultSimilarity object and
attempt to call its tf method (to weight term frequency), it
mishandles the case where it's passed a Python float.  (My application
does this because it's doing the same thing as a Java
SimilarityDelegator, and it just delegates the tf method without
alteration.)  A workaround is to pass a Python integer.

I've attached tf.py, which attempts to demonstrate the problem, and
lucene.cpp.patch (against r290), which seems to fix the problem for me.

   Thanks,
   Aaron Lav ([EMAIL PROTECTED] / http://www.pobox.com/~asl2)
import sys

import PyLucene

store = PyLucene.RAMDirectory()
analyzer = PyLucene.StandardAnalyzer()
writer = PyLucene.IndexWriter(store, analyzer, True)
similarity = writer.getSimilarity()

print similarity, similarity.tf(2.0), similarity.tf(2)
assert similarity.tf(2.0) == similarity.tf(2)

Index: lucene.cpp
===================================================================
--- lucene.cpp  (revision 290)
+++ lucene.cpp  (working copy)
@@ -9430,7 +9430,7 @@
     }
     if (!parseArg(arg, "d", &d))
     {
-        OBJ_CALL(f = self->object->tf((jfloat) f));
+        OBJ_CALL(f = self->object->tf((jfloat) d));
         return PyFloat_FromDouble((double) f);
     }
         
_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev

Reply via email to