[Zope-CVS] CVS: Products/ZCTextIndex/tests - mailtest.py:1.13

Tim Peters tim.one@comcast.net
Tue, 28 May 2002 19:42:20 -0400

Update of /cvs-repository/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv24154/tests

Modified Files:
Log Message:
OkapiIndex.query_weight():  return an upper bound on possible doc scores.

CosineIndex.query_weight():  rewrote to squash code duplication.  No
change in what it returns (it's always returned an upper bound on
possible doc scores, although people probably haven't thought of it
that way before).

Elsewhere:  consequent changes.


+ mhindex.py needs repair, but I can't run it.  Note that its current
  use of query_weight isn't legitimate (the usage doesn't conform to
  the IIndex interface -- passing a string is passing "a sequence",
  but not the intended sequence <wink>).

+ ZCTextIndex doesn't pass query_weight() on.

+ We've defined no methods to help clients compute what needs to be
  passed to query_weight (a sequence of only the positive terms).

  I changed mailtest.py to cheat, but it's doing a wrong thing for
  negative terms.

+ I expect it will be impossible to shake people from the belief that
  100.0 * score / query_weight is some kind of "relevance score".  It
  isn't.  So perhaps better not to expose this in ZCTextIndex.

=== Products/ZCTextIndex/tests/mailtest.py 1.12 => 1.13 ===
     print "# results:", len(results), "of", num_results, \
           "in %.2f ms" % (elapsed * 1000)
+    qw = idx.index.query_weight([query_str])
     for docid, score in results:
-        print "docid %4d score %2d" % (docid, score)
+        scaled = 100.0 * score / qw
+        print "docid %7d score %6d scaled %5.2f%%" % (docid, score, scaled)
         if VERBOSE:
             msg = docs[docid]
             ctx = msg.text.split("\n", CONTEXT)