Commit 7306464c authored by Tim Peters's avatar Tim Peters

Compuate query_weight a right(er) way.

parent 99c6aaae
...@@ -46,6 +46,7 @@ from Products.ZCTextIndex.Lexicon import \ ...@@ -46,6 +46,7 @@ from Products.ZCTextIndex.Lexicon import \
Lexicon, CaseNormalizer, Splitter, StopWordRemover Lexicon, CaseNormalizer, Splitter, StopWordRemover
from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex
from BTrees.IOBTree import IOBTree from BTrees.IOBTree import IOBTree
from Products.ZCTextIndex.QueryParser import QueryParser
import sys import sys
import mailbox import mailbox
...@@ -161,7 +162,10 @@ def query(rt, query_str): ...@@ -161,7 +162,10 @@ def query(rt, query_str):
print "query:", query_str print "query:", query_str
print "# results:", len(results), "of", num_results, \ print "# results:", len(results), "of", num_results, \
"in %.2f ms" % (elapsed * 1000) "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: for docid, score in results:
scaled = 100.0 * score / qw scaled = 100.0 * score / qw
print "docid %7d score %6d scaled %5.2f%%" % (docid, score, scaled) print "docid %7d score %6d scaled %5.2f%%" % (docid, score, scaled)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment