Gossamer Forum
Home : Products : Links 2.0 : Customization :

Relevency search

Quote Reply
Relevency search
Just interested, did anyone manage to find a solution to this in the end.

Good Luck!

Glenn


http://cgi-resource.co.uk
Quote Reply
Re: Relevency search In reply to
I did...but the codes are unclean and not suitable for distribution...and also, since I have upgraded to LINKS SQL, I am not using the hacks that I applied since they are incompatible with the LINKS SQL version...

And I believe that Bmxer came up with a solution awhile back, although he hasn't been around the forum in a few months.

Regards,

Eliot Lee
Quote Reply
Re: Relevency search In reply to
I've been playing around with search.cgi today and got a working solution. Probably not the most efficient solution or neatest but it seems to work fine.

So far each of the search words are matched against the values in user defined relevency fields such as title, description etc...

If there's a match in any field it'll add a value of one to a variable. If there's a match in the title field it'll add a higher value (for instance 2).

The links will then be sorted by this array. A revelvency %percentage is returned next to each link (worked out by dividing the relevency score for the site by the max relevency a site could acheive from using those keywords)

What it doesn't do is say if a word is repeated more than once in description, it'll only match/count that word once. Which I thought would be a good thing to stop people repeating a word and effectively spamming the search engine.

Good Luck!

Glenn


http://cgi-resource.co.uk
Quote Reply
Re: Relevency search In reply to
Here's an example:

http://cgi-resource.co.uk/....cgi?query=test+link

If anyones interested I can post some instructions in a few weeks time.

Good Luck!

Glenn


http://cgi-resource.co.uk
Quote Reply
Re: Relevency search In reply to
More than interested, Glenn! It would be a great tool to improve search results.

Thomas
http://www.japanreference.com
Quote Reply
Re: Relevency search In reply to
No problem, I'll leave it a few weeks because although it's working, I think certain pieces can be improved on. For example some of the code could probably be put inside some of the existing loops rather than using a seperate loop.

It'll be easy to change the set up. For example you could change the relevency weightings given to title, description or any other fields you use it on.

Good Luck!

Glenn


http://cgi-resource.co.uk
Quote Reply
Re: Relevency search In reply to
Ohh yes, I would even be VERY INTERESTED!

....and with the code you already provided me I changed my search.cgi so alsow links that didn't match the searchterm are now displayed. So now I have all my matched links displayed followed by all others links in that category.

Keep up the good work Glennu, you'r our king :-)


Quote Reply
Re: Relevency search In reply to
Glennu,

Just a quick question......the first and second links in that url you provided both have the same relevancy % (62%) yet the first link has the word "test" in it three times and the word "link" once, and the second link has the word "test" only twice - so how come the % is the same?...Is that meant to happen?

Also the last two links both contain "test" and "link" but one is 50% the other is 25%

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Relevency search In reply to
'Just a quick question......the first and second links in that url you provided both have the same relevancy % (62%) yet the first link has the word "test" in it three times and the word "link" once, and the second link has the word "test" only twice - so how come the % is the same?...Is that meant to happen?'

Yep this is meant to happen. Otherwise people could just repeat a popular word in the description of their site so as they get a higher ranking in the search results. So in this example test is repeated twice in the description but it is only counted once for the relevency.


'Also the last two links both contain "test" and "link" but one is 50% the other is 25%'

Yep that's also meant to happen. Different fields carry different relevency weightings. For instance the way I have it at the moment if a word is found in the title it is twice as relevent as a word found in the description.


Good Luck!

Glenn


http://cgi-resource.co.uk
Quote Reply
Re: Relevency search In reply to
Ahh ok I C - thats for explaining that.

Nice mod by the way - for someone who has limited free time you sure hammer out these mods - nice work!

If no-one is having any luck with the dynamic category mod then I am happy to try it out to give some feedback.

May do that now actually.

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Relevency search In reply to
Glennu,

Looks like a typo in your "sub-cat on main page" mod....

if ($name{$values} =~ m,.*/([^/]+)$,) { $name{$values} = &build_clean($1); } else { $nam{$values} = &build_clean($subcat); }

Should be.....

if ($name{$values} =~ m,.*/([^/]+)$,) { $name{$values} = &build_clean($1); } else { $name{$values} = &build_clean($subcat); }

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Relevency search In reply to
It's not a typo...

$nam is for building the category names clean and
$name is the original one used for the URL link.


I probably should have given it a more relevent name!



Good Luck!

Glenn


http://cgi-resource.co.uk
Quote Reply
Re: Relevency search In reply to
Oops,

Also sorry to be a pain but I can't get your search by letter mod to work either.

I followed your instructions but changed $in{'letter'} to $in{'lt'} but I can't seem to get it to work. It just queries the database as normal and returns links starting with any letter.

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Relevency search In reply to
eeeeeww

just got this....

Error Message : fatal error: /^[]/: unmatched [] in regexp at /home/sites/site6/web/cgi-bin/search.cgi line 219, chunk 1.


Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Relevency search In reply to
Not sure because it works fine for me! Try the following:

(this is a better expression to use and I'll alter it on my site soon)

instead of:

$_ = "\U$values[$db_title]\E";
$charfirst = "$in{'letter'}";
if (m/^[$charfirst]/) {


Try using:

$_ = $values[$db_title];
$charfirst = "$in{'letter'}";
if (m/^[$charfirst]/i) {


Now you can link to it using either lower or upper case letters. (ie. it's now case insensitive).

Good Luck!

Glenn


http://cgi-resource.co.uk
Quote Reply
Re: Relevency search In reply to
Nope that still gives me....

Error Message : fatal error: /^[]/: unmatched [] in regexp at /home/sites/site6/web/cgi-bin/search.cgi line 219, chunk 1.



Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Relevency search In reply to
Just tested it on my offline site again and it still works for me. The only time I can see that error is if I leave out the letter field.

Good Luck!

Glenn


http://cgi-resource.co.uk
Quote Reply
Re: Relevency search In reply to
Yes thats what I was doing - with the letter field it works but lists all results as normal and not by letter and without it gives the error.

Wouldn't it be better to make it so the letter isn't required otherwise people will be getting errors all the time or if you don't want to use a letter are you supposed to use...

http://www.domain.com/cgi-bin/search.cgi?query=bla&letter=

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Relevency search In reply to
'Yes thats what I was doing - with the letter field it works but lists all results as normal and not by letter and without it gives the error.'


Not sure what to suggest. It works fine for me!

'Wouldn't it be better to make it so the letter isn't required otherwise people will be getting errors all the time or if you don't want to use a letter are you supposed to use... '

Could do but I didn't think it's neccessary as if you didn't want to use the letter search option you'd just put:

http://www.domain.com/cgi-bin/search.cgi?query=bla&letter=A-Z0-9



Good Luck!

Glenn


http://cgi-resource.co.uk
Quote Reply
Re: Relevency search In reply to
Could you not do something like this....

$letter = $in{'letter'};

Then get $data[$db_title];

Then use $db_letter = substr($data[$db_title],0,1);

Then...

if ($letter eq $db_letter) {
return all links who's title start with that letter
}

Would that not work?

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: Relevency search In reply to
Or you could just put:
$letter2 = ($in{'letter'} =~ /[A-Za-z]+/ ? "$in{'letter'}" : "A-Z0-9");

above the $charfirst statement and use:

$charfirst = "$letter2";

instead of $charfirst = "$in{'$letter'}";

Didn't do it before because I didn't think people would mind putting in a hidden value but I guess it's easier/better to avoid using a hidden value where possible. Cause then every search box doesn't need to be altered.



Good Luck!

Glenn


http://cgi-resource.co.uk
Quote Reply
Re: Relevency search In reply to
'Would that not work?'

Don't know, could do but I'd prefer using a regular expression.

Good Luck!

Glenn


http://cgi-resource.co.uk