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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
compare words - detect misspelling

 



RussianSpy
Novice

Feb 23, 2003, 9:59 AM

Post #1 of 2 (393 views)
compare words - detect misspelling Can't Post

when comparing 2 words, how to detect if one is possible a misspelled version of the other one? like korrect-vs-correct or corect-vs-correct. all the scripts i found load the dictionary of correct words into hash and the instant lookup (?), but in my script i have the dictionary loaded in array and i go through each word in "for" loop, doing some other substring search. so i'd need to do it w/o a hash. so, how?

i don't even know the definition of "misspelled". i guess it means 1-2 different letters in those words and/or 1-2 letters extra or missing?

so is there a way to do it?

here's a script i found that's using hash, but i only partially understand how it works and i totaly don't understand where it compares words :-/


Code
 %dictionary = map { $_, 1 } qw(cat dog man woman hat glove); 
@words = qw(dog kat wimen hat man glov);
foreach $word (@words) {
if (not $dictionary{$word}) {
print "Possible misspelled word: $word\n";
}
}



Possible misspelled word: kat
Possible misspelled word: wimen
Possible misspelled word: glov

i'd really appreciale any help or if someone can point me to the right direction if its a complicated matter...

TIA!
_________________________________________________
[ noobie alert ] WinXP :: Xitami Webserver :: Active Perl 5.8.6


davorg
Thaumaturge / Moderator

Feb 24, 2003, 1:50 AM

Post #2 of 2 (387 views)
Re: [RussianSpy] compare words - detect misspelling [In reply to] Can't Post

It's not an easy problem to solve. You might take a look at Text::Soundex (included with the standard Perl distribution) or String::Approx.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


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

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