Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Compuate query_weight a right(er) way.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Peters committed May 29, 2002
1 parent 8d8afd8 commit 4e6a4dc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/mailtest.py
Expand Up @@ -46,6 +46,7 @@
Lexicon, CaseNormalizer, Splitter, StopWordRemover
from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex
from BTrees.IOBTree import IOBTree
from Products.ZCTextIndex.QueryParser import QueryParser

import sys
import mailbox
Expand Down Expand Up @@ -161,7 +162,10 @@ def query(rt, query_str):
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)
Expand Down

0 comments on commit 4e6a4dc

Please sign in to comment.