Commit eb784ec3 authored by Guido van Rossum's avatar Guido van Rossum

Fix the query weight computation.

parent 71b1e2bc
...@@ -290,7 +290,7 @@ class Indexer: ...@@ -290,7 +290,7 @@ class Indexer:
n = path[i+1:] n = path[i+1:]
cmd = "show +%s %s" % (folder, n) cmd = "show +%s %s" % (folder, n)
if os.getenv("DISPLAY"): if os.getenv("DISPLAY"):
os.system("xterm -e %s &" % cmd) os.system("xterm -e sh -c '%s | less' &" % cmd)
else: else:
os.system(cmd) os.system(cmd)
...@@ -320,12 +320,11 @@ class Indexer: ...@@ -320,12 +320,11 @@ class Indexer:
prog = re.compile(pattern, re.IGNORECASE) prog = re.compile(pattern, re.IGNORECASE)
print '='*70 print '='*70
rank = lo rank = lo
qw = max(1, self.index.query_weight(text)) qw = self.index.query_weight(text)
factor = 100.0 / qw / 1024
for docid, score in results[lo:hi]: for docid, score in results[lo:hi]:
rank += 1 rank += 1
path = self.docpaths[docid] 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) print "Rank: %d Score: %d%% File: %s" % (rank, score, path)
path = os.path.join(self.mh.getpath(), path) path = os.path.join(self.mh.getpath(), path)
fp = open(path) fp = open(path)
......
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