fuzzy comparing

This is a discussion on fuzzy comparing within the C++ Programming forums, part of the General Programming Boards category; I have two strings. The strings are for example like this : string1 = "swim foward" string2 = "smim foward" ...

  1. #1
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377

    Wink fuzzy comparing

    I have two strings. The strings are for example like this :
    string1 = "swim foward"
    string2 = "smim foward"
    So when i compare them, they are not equal.
    Can i compare them somehow, so that i know they look alike?
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    What do you mean "look alike"? You mean if they're close enough like the example you gave (perhaps to check for typos)?
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    you could count charactors that are the same and use that as an indication of how alike the strings are.

  4. #4
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    Quote Originally Posted by SlyMaelstrom
    What do you mean "look alike"? You mean if they're close enough like the example you gave (perhaps to check for typos)?
    exactly.
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    Yes.

    String length / number of matched characters * 100 = percentage of similarity between strings

    Just be careful if you were planning to autocorrect strings, as there are similar correct words.
    Think:

    "Meet me in the car"
    "Meet me in the bar"
    Sent from my iPadŽ

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535

  7. #7
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    How well does that work for pure typing errors?

    I can see that working good for phonetics such as someone spelling "knife" as "nife" or "phone" as "fone", but lets say someone wrote "phgonbe" instead of "phone".
    Sent from my iPadŽ

  8. #8
    the Great ElastoManiac's Avatar
    Join Date
    Nov 2005
    Location
    Republika Srpska - Balkan
    Posts
    377
    allright i got it, thanks for the help.
    lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with comparing strings!
    By adrian2009 in forum C Programming
    Replies: 2
    Last Post: 02-28-2009, 09:44 PM
  2. bit vs bytes when comparing a file
    By Overworked_PhD in forum C Programming
    Replies: 6
    Last Post: 05-19-2007, 11:22 PM
  3. comparing bitmaps
    By bigSteve in forum C++ Programming
    Replies: 1
    Last Post: 11-08-2002, 09:40 AM
  4. comparing problem
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 03-05-2002, 05:19 AM
  5. comparing struct members
    By breed in forum C Programming
    Replies: 4
    Last Post: 11-22-2001, 11:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21