CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
help with following code


Tehmina Iqbal

Mar 26, 2011, 9:34 AM

Post #1 of 2 (395 views)
help with following code Can't Post

the following code shows me no error msg while running but it keeps on running without showing any output until i forefully terminate it. while debugging it shows values before line # 11 but when it comes to line # 11 i have to keep on pressing f8 key for 13 or 14 times and then it stops debugging. it happens when we call build index function.

use Search::VectorSpace;

open instream, "D:/coding/d1.txt";
$/=undef; # It is used read all text at once from the file.
@docs = <instream>;
close instream ;
print @docs;

my $engine = Search::VectorSpace->new( docs => \@docs );

$engine->build_index(); # i can debug till here and then it stops...
$engine->set_threshold( 0.8 );

while ( my $query = <> ) {
my %results = $engine->search( $query );
foreach my $result ( sort { $results{$b} <=> $results{$a} }
keys %results ) {
print "Relevance: ", $results{$result}, "\n";
print $result, "\n\n";

print "Next query?\n";

i am attaching the file

plz help me to run this code
Attachments: (8.44 KB)


Mar 26, 2011, 9:51 AM

Post #2 of 2 (393 views)
Re: [Tehmina Iqbal] help with following code [In reply to] Can't Post

Search::VectorSpace doesn't seem to have a set_threshold() method (
Try and do it this way:

my $engine = Search::VectorSpace->new( docs => \@docs, threshold => .08 );

And by the way, "$/ = undef;" is only needed if you want to read a whole file into a scalar, an array gets the whole file without it.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives