Message Boards Message Boards

Is there a "compare" function to compare text vs a control?

Posted 8 years ago

I'm still working through my first program with Mathematica. As it goes I want to "TextRecognize" (successful there) and compare the text output vs a control. My first thought was to shorten the output to about 9 characters (enough for the purposes of a prototype) and at first I wanted to make a hard compare with "SmithWatermanSimilarity" or "NeedlemanWunschSimilarity" or "EditDistance". Now I'm thinking I want to compare the output vs a small control list and have wolfram tell me which item my output is most like.

Example:

  • Out[36] Pog
  • is %36 most like {Dog, Pat, Cat}
  • Out[37] 1

Thoughts? Suggestions? Thanks guys (and ladies)

POSTED BY: Bill Norman
5 Replies

Note that Nearest uses the EditDistance to compare strings, but you can change that if you want (DistanceFunction). Good luck.

POSTED BY: Sander Huisman
Posted 8 years ago

Sander. Thank you. That's Perfect.

POSTED BY: Bill Norman
Nearest[{"Dog", "Pat", "Cat"}, "Pog"]

"Dog"
POSTED BY: Sander Huisman
Posted 8 years ago

Thanks Bill (it's always neat meeting another Bill) I found the "StringTake" command and it worked perfectly. I updated my post with the next hurdle in my programming. ^__^

POSTED BY: Bill Norman
Posted 8 years ago

Please report what

FullForm[TextRecognize[...yourimage...]]

displays.

Mathematica by default hides quotes around strings and when a function doesn't understand an argument then by default it just returns the original expression. FullForm should help diagnose what is being returned.

POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract