Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

sorting a search result?

by nimfa (Initiate)
on Nov 28, 2001 at 00:56 UTC ( [id://127910]=perlquestion: print w/replies, xml ) Need Help??

nimfa has asked for the wisdom of the Perl Monks concerning the following question:

Hello! i would like to know if the source code for this site is available and if so where can i get it?

and i would like some help on, sorting the result of a search or the search result!

im new in perl, and i got this free script for my site, it index my html files in a text file! and i would like the result sorted much like in this sites search script! so the most relevant are first! thnks

my result is being stored in a hash! i think its this?
$result{$filename}[1]=$title; $result{$filename}[2]=$description; $result{$filename}[3]=$size; $result{$filename}[4]=localtime($mtime);

Replies are listed 'Best First'.
Re: sorting a search result?
by Fastolfe (Vicar) on Nov 28, 2001 at 01:19 UTC

    The answer that's going to do you the most good is this: Buy a copy of Learning Perl and check out the standard documentation for the sort function and the Perl Data Structures Cookbook, the latter of which even has code examples for doing precisely this.

    Alternatively, you can go back to the author of this script and ask him to add this functionality.

Re: sorting a search result?
by Dogma (Pilgrim) on Nov 28, 2001 at 05:38 UTC
    You might want to take a look at "Mastering Algorithms with Perl". It spends a fair amount of time dealing with sorting algorithms. If you have a large amount of data to deal with it can be a life saver.
Perlmonks source code
by IlyaM (Parson) on Nov 28, 2001 at 05:32 UTC
    Hello! i would like to know if the source code for this site is available and if so where can i get it?

    Yes. It is avialable. Look here.

Re: sorting a search result?
by fuzzysteve (Beadle) on Nov 28, 2001 at 04:05 UTC
    real problem here? deciding how relevant each result is. thats always going to be the problem. I'd assume that the script you have only searchs for each word, and once it finds it, it stores the file it found it in, and goes on to the next. If this is the case, you'll have to rewrite the script to provide some kind of weighting to the data (perhaps how many times the words appear, or how close they are to each other)
    Sorry to say, but you've picked a deceptivly complex task to start on.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://127910]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-24 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found