PDA

View Full Version : "Did you mean" behavior


mkirk
09-28-2004, 05:03 AM
Sorry, just wrote a long post and was given the login prompt again when hit post, so I'll be briefer on this one.

I'm testing v1.8.3 at http://****verma.gov/dig/ (the one in the title bar goes to an earlier version, so you'll need to use that url).
When I search for 'board of assessors', v1.8.3 returns results correctly after ignoring of and using the default AND operator. But if I intentionally mispell a word, as in "board of assesors", it recommends "bird assessors". I'd recommend a better way would be to only offer replacements for words each individual word does not produce results. Long story short, 'bird' shouldn't have been offered.

By the way, 'did', 'you' and 'mean' are all ignored words on the forum search, so I apologize if there is another thread that talks about this.

Thanks!
Mike

renehaentjens
09-28-2004, 10:50 PM
PhpDig 1.8.3 mimics the Big-Brother-like attitude of Google, telling the user to try another keyword if it didn't find anything, often giving silly or irritating suggestions, at least in my opinion.

I have a showcase on aquaculture (fish & seafood production) and searched for keywords "feed-production" and "scheme". As PhpDig didn't find anything, it told me: No results. Did you mean china?

Can I change the way in which PhpDig comes up with a new suggestion, to enhance it for my environment?

If not, or if difficult, can I switch it off?

jabdulla
10-17-2004, 01:07 PM
I noticed the "Did you mean" feature was related to a value called "alt_try". The file "libs/search_function.php" contains the "alt_try" value in a function on line 629. That line is simply appending text to the result message. I commented out the line, and the "Did you mean" no longer displays.

Here is line 629 (commented out).

//$result_message .= ". " . phpdigMsg('alt_try') ." <a class=\"phpdigMessage\" href=\"".SEARCH_PAGE."?page=search&template_demo=".$_GET['template_demo']."&
query_string=".urlencode($leven_query)."\"><i>".htmlspecialchars($leven_query)."</i></a>?";

renehaentjens
10-28-2004, 04:05 AM
Thank you jabdulla!

I looked at the code just above, then at the PHP and MySQL documentation, and learned something about soundex (PHP and MySQL, but different), the importance of adding a letter in front (e.g. Q), levenshtein, metaphone and other strange animals.

As my keywords are arranged in a tree, thesaurus-like, I might suggest the user to search with a broader term (e.g. "flatfish", in case a search on "sole" did not return any results) rather than a sound-alike ("shark" instead of "carp"?). Also, the user clicks in the keyword tree, which means that misspellings (MESSING PILLS? SMELL PIG SINS? MINGLES SLIPS?) do not occur all that often (no need for ELEVENTH SIN). harsh reality...
http://www.wordsmith.org/anagram/index.html