Re: Re: [htdig] PERCENT returning 1% on big hits

"Joe R. Jah" <[email protected]>
Newsgroups gmane.comp.web.htdig.devel,gmane.comp.web.htdig.general
Message-ID <[email protected]>
On Thu, 1 Jul 2004, Jim wrote:

> Date: Thu, 1 Jul 2004 15:45:10 -0600 (MDT)
> From: Jim <[email protected]>
> To: Eli White <[email protected]>
> Cc: [email protected], [email protected]
> Subject: [htdig-dev] Re: [htdig] PERCENT returning 1% on big hits
> 
> On Thu, 1 Jul 2004, Eli White wrote:
> 
> > In fact, due to cross-linking of terms, some of those can have a VERY HIGH 
> > score.
> > 
> > The problem is, that at some point, it seems we passed a threshold, and for 
> > those extremely high hits, the PERCENT result is messed up.
> > 
> > It appears as if it occurs when it wants to give a score HIGHER than 100%, 
> > and ends up printing 1% instead.
> 
> Looks like a bug has crept into the handling of PERCENT. As you indicate,
> the problem is in fact tied to high scores. The score, which is stored as
> an int, is multiplied by 100 (literal), resulting in an overflow whenever
> the score is much more than 20 million. If the result ends up negative,
> percent is manually set to 1; otherwise you just get whatever garbage
> resulted from the overflow.
> 
> Based on a quick look, I think it is an easy fix. However you would need
> to touch the source and rebuild at least htsearch. My assumption is that
> if you replace the 100 with 100.0 at line 314 of htsearch/Display.cc (for
> ht://Dig 3.1.6), then you will avoid the overflow and correct the problem
> you are encountering. I haven't actually tested this. If you are able to
> test this and it solves the problem, please let us know. You might also
> consider submitting a bug report if you get a chance just to make sure
> this issue doesn't get lost in the shuffle.
> 
> Jim

I can't test your fix either, but I have put it as a patch in:

  ftp://ftp.ccsf.org/htdig-patches/3.1.6/percent.0

If it works we can fix 3.2.0b6 too:

--- htsearch/Display.cc.orig	Fri May 28 06:15:24 2004
+++ htsearch/Display.cc	Thu Jul  1 15:51:29 2004
@@ -362,7 +362,7 @@
 
     if (maxScore != 0 && maxScore != minScore)
       {
-	int percent = (int)((ref->DocScore() - minScore) * 100 /
+	int percent = (int)((ref->DocScore() - minScore) * 100.0 /
 			    (maxScore - minScore));
 	if (percent <= 0)
 	  percent = 1;

Regards,

Joe
-- 
     _/   _/_/_/       _/              ____________    __o
     _/   _/   _/      _/         ______________     _-\<,_
 _/  _/   _/_/_/   _/  _/                     ......(_)/ (_)
  _/_/ oe _/   _/.  _/_/ ah        [email protected]

> > Can anyone shed some light on why this is happening?  It happens with 3.1.5 
> > AND 3.1.6 ...
> > 
> > Some example star/percent/score results to peruse:
> > 
> > Search (A)
> > Result 1:  1% - 5 stars - score: 40695460
> > Result 2: 24% - 2 stars - score:  9850704
> > Result 3: 24% - 2 stars - score:  9808377
> > Result 4: 16% - 2 stars - score:  8606539
> > 
> > Search (B)
> > Result 1: 11% - 5 stars - score: 48628560
> > Result 2: 43% - 3 stars - score: 21387546
> > Result 3: 23% - 2 stars - score: 11271058
> > Result 4: 17% - 2 stars - score:  8733621
> > 
> > Search (C)
> > Result 1:  1% - 5 stars - score: 761285184
> > Result 2:  1% - 1 star  - score:  51412848
> > Result 3:  1% - 1 star  - score:  43010124
> > Result 4:  2% - 1 star  - score:  20066298
> > 
> > And so on ...
> > 
> > Thanks in advance,
> > Eli



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
ht://Dig Developer mailing list:
[email protected]
List information (subscribe/unsubscribe, etc.)
https://lists.sourceforge.net/lists/listinfo/htdig-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.