Skip to main content.
home | support | download

Back to List Archive

Re: modifying the score...

From: Kenneth Green <kenneth_green(at)not-real.hp.com>
Date: Wed Dec 16 1998 - 21:53:10 GMT
David,

I use swish-e and a modified version of the sample script
'swish-bin.cgi'. I have made a modification to that script which
optionally converts the score to a percentage. Have a look at the
code samples below to see how this was done.

I hope this helps.

Rgds,
Kenneth

------------------------------

+-----------------------------------------------------------------+
| Code snippets from modified version of "swish-bin.cgi" relating |
| to reprsenting score as a percentage                            |
+-----------------------------------------------------------------+

1) Added formatting  control 'ScoreAsPercent':

 #---------------------------------------------------------------------
 # Formatting controls
 #
 #  $ShowFilePaths      - display pathname for index in 'Data about 
 #  $PrintBoldLinks     - use Bold for hyperlinks
 #  $PrintRawLinks      - display URL as well as page Title
 #  $HotlinkURLs        - display URL as a link rather than plain text
 #  $PrintHitOnOneLine  - display all hit info on a single line
 #  $PrintHitSize       - display hit page size in bytes
 #  $PrintHitDate       - display hit page file date
 #  $ScoreAsPercent     - display the hit relevance as a percentage
 #  $GoofyKeyword       - internal variable - do not change
 #---------------------------------------------------------------------
 $ShowFilePaths          = 0;
 $PrintBoldLinks         = 0;
 $PrintRawLinks          = 0;
 $HotlinkURLs            = 0;
 $PrintHitOnOneLine      = 1;
 $PrintHitSize           = 0;
 $PrintHitDate           = 0;
 $ScoreAsPercent         = 1;
 $GoofyKeyword           = "oQiTb2lkCv";

2) Modified the function 'PrintLink' and added 'PrintLinkScore':

 #-------------------------------------------------------------------
 # PRINT LINK
 #-------------------------------------------------------------------
 #
 # -C3- begin
 #
 # Print out a hit formatted as:
 #
 #  hitNumber. hitPageTitle_as_link
 #              hitLink_as_link
 #              hitRelevanceScore, hitPageSize, hitPageDate - 
hitFiletype
 # OR as
 #
 #  hitNumber. (relevanceScore, hitPageSize, hitPageDate) 
hitPageTitle_as_link
 #
 #
 # NOTE: Newline characters are inserted into the generated HTML 
primarily
 #       as an aid to human readability and hence debugging
 # 
 sub PrintLinkScore
 {
   if ($ScoreAsPercent)
   {
     $pcent = 1 + $ScoreArray[$ArrayIndex]/10;
     $pcent =~ s/\..*//;   # remove everything after the first decimal 
point
     if ($pcent > 100)
     {
       $pcent = 100;
     }
     print "<tt>";
     if ($pcent < 10)
     {
       print "&nbsp&nbsp";
     }
     else
     {
       if ($pcent < 100)
       {
         print "&nbsp";
       }
     }
     print "$pcent%</tt>";
   }
   else
   {
     print "$ScoreArray[$ArrayIndex] score";
   }
   if ($PrintHitSize || $PrintHitDate)
   {
     print ", ";
   }
 }

 #-------------------------------------------------------------------

 sub PrintLink
 {
   print "<p>";
   print "<dt>$LineNumber. ";

   if ($PrintHitOnOneLine)
   {
     print "<small><tt>(";
     &PrintLinkScore;
     &PrintLinkSize;
     &PrintLinkDate;
     print ")</tt></small>&nbsp&nbsp";
     &PrintLinkTitle;
     print "</dt>\n";
   }
   else
   {
     &PrintLinkTitle;
     print "</dt>\n<small><dd>";
     &PrintRawLink;
     print "<dd>";
     &PrintLinkScore;
     &PrintLinkSize;
     &PrintLinkDate;
     &PrintLinkFiletype;
     print "</dd></small>\n\n"
   }
   $LineNumber ++;
 }

--------------<end snippets>-----------


David Richard wrote:
> 
> I'm using Swish-E/wwwwais to index and search my site. Currently, the
> score
> that is returned for files found with swish is in the range of 0 ->
> 1000.
> I would like to change this so that the range of values is between 0
> ->
> 100.  What do I need to modify (eg. where - and how, for that matter -
> are
> the scores calculated?)?
> 
> I'm not afraid to crack open files, modify them and recompile the
> whole
> thing.  I just want to know where to begin looking...
> 
> david
> _____________________________________________________
> David S. Richard           <mailto:david@monkey.com>
> 
> Information Architect
> MONKEYmedia - Austin, Texas
> (512) 440-8000 x.14, 440-1050 fax
> <http://www.monkey.com/>

-- 
========================================================================
Kenneth Green                           +61 3 9210 5541 Tel. & Voicemail
R&D Project Manager                     +61 3 9210 5550 FAX
                                        kenneth_green@hp.com
Advanced Networks Division              PO Box 221, Blackburn Vic 3130
Hewlett-Packard Australia Ltd           AUSTRALIA
========================================================================
Received on Wed Dec 16 13:55:04 1998