how do I query a database to find words that sound similar to each other

how do I query a database to find words that sound similar to each other
I have heard of things like soundex but do not know how to use them?
Dov_BAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
alpmoonCommented:
If you are SQL Server (or Sybase) you can use soundex function for that purpose:

http://msdn.microsoft.com/en-us/library/aa259235%28v=sql.80%29.aspx
0
Dov_BAuthor Commented:
what do I do if i am using sqlite?
I know it supports soundex but it does not support the difference function
what would be an apropriate work around
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Wasim Akram ShaikCommented:
yes, soundex function is used to find similar words based on the algorithm.

placing the extract from wikipedia about the rules of soundex

The following rules are applied when calculating the SOUNDEX for a string:

    Keep the first letter of the string and remove all other occurrences of the following letters: a, e, h, i, o, u, w, y
    Assign numbers to the remaining letters (after the first) as follows:
        b, f, p, v = 1
        c, g, j, k, q, s, x, z = 2
        d, t = 3
        l = 4
        m, n = 5
        r = 6
    If two or more letters with the same number were adjacent in the original name (before step 1), or adjacent except any intervening h's and w's, then remove all but the first.
    Return the first four bytes padded with 0.

complete details can be found at http://en.wikipedia.org/wiki/Soundex

eg: the below query will retrieve records from db as

LAST_NAME  FIRST_NAME
---------- ----------
Smith      Lindsey
Smith      William

SELECT last_name, first_name
     FROM hr.employees
     WHERE SOUNDEX(last_name)
         = SOUNDEX('SMYTHE');
this example is an extract from http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions148.htm
0
Dov_BAuthor Commented:
thanks so much but I need to find matches that are not perfect  the difference function work around would be exteremely helpful
0
Dov_BAuthor Commented:
I am trying out this code in acces but have no Idea how to use it any pointers would be helpful
Public Function Soundex(varText As Variant) As Variant
On Error GoTo Err_Handler
    'Purpose:   Return Soundex value for the text passed in.
    'Return:    Soundex code, or Null for Error, Null or zero-length string.
    'Argument:  The value to generate the Soundex for.
    'Author:    Allen Browne (allen@allenbrowne.com), November 2007.
    'Algorithm: Based on http://en.wikipedia.org/wiki/Soundex
    Dim strSource As String     'varText as a string.
    Dim strOut As String        'Output string to build up.
    Dim strValue As String      'Value for current character.
    Dim strPriorValue As String 'Value for previous character.
    Dim lngPos As Long          'Position in source string
   
    'Do not process Error, Null, or zero-length strings.
    If Not IsError(varText) Then
        strSource = Trim$(Nz(varText, vbNullString))
        If strSource <> vbNullString Then
            'Retain the initial character, and process from 2nd.
            strOut = Left$(strSource, 1&)
            strPriorValue = SoundexValue(strOut)
            lngPos = 2&
           
            'Examine a character at a time, until we output 4 characters.
            Do
                strValue = SoundexValue(Mid$(strSource, lngPos, 1&))
                'Omit repeating values (except the zero for padding.)
                If ((strValue <> strPriorValue) And (strValue <> vbNullString)) Or (strValue = "0") Then
                    strOut = strOut & strValue
                    strPriorValue = strValue
                End If
                lngPos = lngPos + 1&
            Loop Until Len(strOut) >= 4&
        End If
    End If
   
    'Return the output string, or Null if nothing generated.
    If strOut <> vbNullString Then
        Soundex = strOut
    Else
        Soundex = Null
    End If
   
Exit_Handler:
    Exit Function
   
Err_Handler:
    MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation, "Soundex()"
    'Call LogError(Err.Number, Err.Description, conMod & ".Soundex")
    Resume Exit_Handler
End Function
Private Function SoundexValue(strChar As String) As String
    Select Case strChar
    Case "B", "F", "P", "V"
        SoundexValue = "1"
    Case "C", "G", "J", "K", "Q", "S", "X", "Z"
        SoundexValue = "2"
    Case "D", "T"
        SoundexValue = "3"
    Case "L"
        SoundexValue = "4"
    Case "M", "N"
        SoundexValue = "5"
    Case "R"
        SoundexValue = "6"
    Case vbNullString
        'Pad trailing zeros if no more characters.
        SoundexValue = "0"
    Case Else
        'Return nothing for "A", "E", "H", "I", "O", "U", "W", "Y", non-alpha.
    End Select
End Function
0
Wasim Akram ShaikCommented:
you can try jaro wrinkler algorithm to find out the differences..

not sure sqlite has this function implemented or not..

just did a google search and posting an extract , you can go through these links

http://stackoverflow.com/questions/2847603/doing-order-by-using-the-jaro-winkler-distance-algorithm
http://stackoverflow.com/questions/6583588/jarowinkler-as-a-loadable-extension-to-sqlite
0
Jeffrey CoachmanMIS LiasonCommented:
Dov_B,

I'm confused...
Your question:
<how do I query a database to find words that sound similar to each other>
Great, use Soundex...

Now you say:
<I need to find matches that are not perfect>
"Not Perfect"?

The word "Cat" is not a perfect match for the word "Phone", so I am not quite sure what you are asking for?

I am also not sure what you mean by the "Difference Function".


To be clear, why not just post a list of words, then post all the corresponding "Matches" for that word you may be seeking...

Keep in mind that not system to do this will be perfect.
0
Dov_BAuthor Commented:
sorry for all the trouble and thanks for staying with me
It seemed to me that that the difference function used together with the soundex function could create a list of less then perfect matches for example
I would like a query of the word 'difference' to return
france
differ
dance
phorensic
fence
 something like that
I am now going to look at the google posts you left me thanks for your efforts on my behalf
0
Jeffrey CoachmanMIS LiasonCommented:
Then your requirements for this "Matching" is extremely broad...

I don't thing anything will get you that without giving way too much, or way to little...

For example, most of these programs will match the number of "syllables".
'difference' is 3 syllables
"dance" is only one.

By your definition you may also get:
Spiff
Drifter
inference
interference
Stiff
Stiffer
rinse
wrench
since
grifter
...et al


...in  other words, ...any word that sounds like any "syllable" in your reference word...

So you may have to add another algorithm to create a search word for each "Syllable"
:-O

Good luck buddy....
;-)

Jeff
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.