Perlfect Solutions
 

[Perlfect-search] Search scores in percents

Giorgos Zervas giorgos@perlfect.com
Fri, 18 Aug 2000 03:48:43 +0000
Well, you were both faster than me and as you have indicated the right
way is to find the biggest value in %answer then divide every other
value by this number; multiply by 100 and voila you have percentages.
What I wanted to add to the discussion is that percentage scoring is a
feature that is definetely going to be in perlfect search 3.10.

giorgos.

JARED RUSSELL WHITE wrote:
> 
> Thanks, Daniel -
> 
> That certainly is the right way to do it.  I'm not really thinking too
> clearly today!
> 
> If anybody else is interested, here's the code to handle that:
> 
>   my @sortedList = sort {$answer{$b} <=> $answer{$a}} keys %answer;
>   my $percentFactor;
>   if (@sortedList) {
>      $percentFactor = 99.99/$answer{$sortedList[0]};
>   }
> 
>   foreach (@sortedList[$first..$last]) {
>     my $score = sprintf "%.2f%%", $answer{$_} * $percentFactor;
>     ...
> 
> Thanks, again, Dan.
> 
> - Jared White
> 
> On Mon, 21 Aug 2000, Daniel Naber wrote:
> 
> > On Mon, 21 Aug 2000, you wrote:
> >
> > >     my $score = sprintf "%.2f%%", $answer{$_};
> >
> > You can do this and check if the value is > 100, if it is: $score = 100;
> > (not a clean solution).
> >
> > The right way would be to go throw all the values in %answer and find the
> > biggest one. Then you can calculate a factor that's necessary to make the
> > biggest one 100 and multiply every value with this factor.
> >
> > Regards
> >  Daniel
> > _______________________________________________
> > perlfect-search mailing list
> > perlfect-search@perlfect.com
> > 
> >
> 
> _______________________________________________
> perlfect-search mailing list
> perlfect-search@perlfect.com
> 

-- 
Perlfect Solutions
http://perlfect.com