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

Commit

Permalink
Fix the query weight computation.
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed May 29, 2002
1 parent 450e673 commit 8d8afd8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests/mhindex.py
Expand Up @@ -290,7 +290,7 @@ def specialcommand(self, line, results, first):
n = path[i+1:]
cmd = "show +%s %s" % (folder, n)
if os.getenv("DISPLAY"):
os.system("xterm -e %s &" % cmd)
os.system("xterm -e sh -c '%s | less' &" % cmd)
else:
os.system(cmd)

Expand Down Expand Up @@ -320,12 +320,11 @@ def formatresults(self, text, results, maxlines=MAXLINES,
prog = re.compile(pattern, re.IGNORECASE)
print '='*70
rank = lo
qw = max(1, self.index.query_weight(text))
factor = 100.0 / qw / 1024
qw = self.index.query_weight(text)
for docid, score in results[lo:hi]:
rank += 1
path = self.docpaths[docid]
score = min(100, int(score * factor))
score = 100.0*score/qw
print "Rank: %d Score: %d%% File: %s" % (rank, score, path)
path = os.path.join(self.mh.getpath(), path)
fp = open(path)
Expand Down

0 comments on commit 8d8afd8

Please sign in to comment.