pASULJ Posted December 22, 2009 Share Posted December 22, 2009 (edited) I am trying to compare two words for similarity. I am using OCR to get one word (second word is 100% correct), but sometimes OCR makes some small errors. So I was thinking it would be good to have some "back test". This is what I came up(in theory) with my limited knowledge: split the word on single characters and compare to other word, character by character, and make it tolerate one or two errors... Any other idea? Edited December 22, 2009 by pASULJ Link to comment Share on other sites More sharing options...
BrettF Posted December 22, 2009 Share Posted December 22, 2009 Well comparison would be intresting. Maybe have a look into how spellcheckers compare your world (misspelled) to words found in their dictionaries... A good time spent on Google wouldn't be too bad either. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
jchd Posted December 22, 2009 Share Posted December 22, 2009 (edited) Any other idea? Hi, You can try my _Typos() function. It returns the Damerau-Levenshtein distance between two strings and accept SQL-like wildcards in patterns as well. Typos.au3 EDIT: the file is UTF-8 with BOM (contains diacritics in the example part). Edited December 22, 2009 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 22, 2009 Moderators Share Posted December 22, 2009 jchd, That is going stright into the Snippets folder! Thank you for sharing it. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
jchd Posted December 22, 2009 Share Posted December 22, 2009 That is going stright into the Snippets folder! Thank you for sharing it. You're welcome.This is a transpose of a small part of an SQLite extension for handling various aspect of Unicode without ICU.To be fully honest, it's rather the contrary: I wrote this one in AutoIt and rewrote it in plain C when debugged ;-) This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
pASULJ Posted December 22, 2009 Author Share Posted December 22, 2009 Really good stuff, tnx! Link to comment Share on other sites More sharing options...
jchd Posted December 22, 2009 Share Posted December 22, 2009 Again, I warn against using it on too long strings: there are better algorithms for handling pages of text. This one is very useful for short strings where one can expect few differences, just like human typos or OCR errors. It's true that letter swapping (the 'Damerau' part) is much less likely in the OCR case, but I believe it isn't worth a separate version. I use the C version zillions times a day since it's a tool of choice to filter out database records containing data "close enough" to user input like names or cities and the like. The C version relies on unaccentuation thru Unicode tries, which would be utterly slow in AutoIt. I intend to release the SQLite extension soon here if anyone show interest. I just added this to my copy of the file, for illustration: ConsoleWrite("Does not always return the absolute minimum edit distance:" & @LF & @TAB & "_Typos('bdac', 'abcd') = " & _Typos('bdac', 'abcd') & @LF) ; abcd --> bacd swap ab --> ba = 1 typo ; bacd --> badc swap cd --> dc = 2 typos ; badc --> bdac swap ad --> da = 3 typos but the function returns 4 Computing the absolute minimum needs a much slower and complex algorithm, but cases like above are really academic corner cases. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now