Jump to content

Comparing words


pASULJ
 Share

Recommended Posts

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 by pASULJ
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 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 here
RegExp tutorial: enough to get started
PCRE 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

  • Moderators

jchd,

That is going stright into the Snippets folder! Thank you for sharing it. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 here
RegExp tutorial: enough to get started
PCRE 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

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 here
RegExp tutorial: enough to get started
PCRE 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...