Skip to main content.
home | support | download

Back to List Archive

Re: using DefaultHighlight

From: J Robinson <jrobinson852(at)not-real.yahoo.com>
Date: Thu Sep 04 2003 - 14:39:09 GMT
Hello all, 
I got this worked out. Posted to the list for
reference! Best- jrobinson

--- Bill Moseley <moseley@hank.org> wrote:
> On Tue, Sep 02, 2003 at 09:53:33AM -0700, J Robinson
> wrote:
> > Hello All,
> > 
> > I'm interested in using the
> SWISH::DefaultHighlight
> > module independently from swish.cgi, but I can't
> quite
> > figure out how to invoke it. [...]

To which Bill replied: 
> They expect the swish-e headers, specifically the
> Wordcharacters is 
> needed to know how to detect words. [...]

With Bill's help and some digging through the code, I
got the example below working (I may have messed
something up in the cut & paste though). Thanks Bill
and the entire SWISH-E team for a great tool.
jrobinson

--- source of test-hilite-example.pl ---

#!/bin/perl -w
# example using DefaultHighlight w/out swish.cgi
use strict;
use lib '/usr/local/lib/swish-e/perl';
use SWISH::DefaultHighlight;
my %header = (    wordcharacters =>       
q{0123456789abcdefghijklmnopqrstuvwxyz});
my %highlight  = (
    show_words      => 4,
    max_words       => 50,
    occurrences     => 5,        
    highlight_on   => '<b>',
    highlight_off  => '</b>',
);

my $text = "one two three four five six ay bee cee dee
ee eff gee aitch ay jay kay el em en oh pee one two
three four five six ay bee cee dee ee eff gee aitch ay
jay kay el em en oh pee one two three four five six ay
bee cee dee ee eff gee aitch ay jay kay el em en oh
pee one two three four five six ay bee cee dee ee eff
gee aitch ay jay kay el em en oh pee"; 

my @phrases = ( ['two'], ['el'], ['pee'] );

my $sho = new SWISH::DefaultHighlight( \%highlight,
\%header );
my $ret = $sho->highlight(\$text, \@phrases,
'swishdescription');
print "'$text'";



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
Received on Thu Sep 4 14:47:36 2003