[Zope-CVS] CVS: Products/ZCTextIndex/tests - mhindex.py:1.13

Guido van Rossum guido@python.org
Wed, 29 May 2002 15:23:30 -0400


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

Modified Files:
	mhindex.py 
Log Message:
Fix the query weight computation.

=== Products/ZCTextIndex/tests/mhindex.py 1.12 => 1.13 ===
         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)
 
@@ -320,12 +320,11 @@
         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)