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

Tim Peters tim.one@comcast.net
Wed, 29 May 2002 16:07:13 -0400


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

Modified Files:
	mailtest.py 
Log Message:
Compuate query_weight a right(er) way.


=== Products/ZCTextIndex/tests/mailtest.py 1.13 => 1.14 ===
 from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex
 from BTrees.IOBTree import IOBTree
+from Products.ZCTextIndex.QueryParser import QueryParser
 
 import sys
 import mailbox
@@ -161,7 +162,10 @@
     print "query:", query_str
     print "# results:", len(results), "of", num_results, \
           "in %.2f ms" % (elapsed * 1000)
-    qw = idx.index.query_weight([query_str])
+
+    tree = QueryParser(idx.lexicon).parseQuery(query_str)
+    qw = idx.index.query_weight(tree.terms())
+
     for docid, score in results:
         scaled = 100.0 * score / qw
         print "docid %7d score %6d scaled %5.2f%%" % (docid, score, scaled)