Re: for x,y in word1, word2 ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Edwin.Madari@VerizonWireless.com

    Re: for x,y in word1, word2 ?

    sounds like *soundex* is what you are looking for. google soundex

    regards
    Edwin

    -----Original Message-----
    From: python-list-bounces+edwin.m adari=verizonwi reless.com@pyth on.org
    [mailto:python-list-bounces+edwin.m adari=verizonwi reless.com@pyth on.org]
    On Behalf Of Marc 'BlackJack' Rintsch
    Sent: Monday, August 11, 2008 3:09 AM
    To: python-list@python.org
    Subject: Re: for x,y in word1, word2 ?


    On Sun, 10 Aug 2008 23:14:50 -0700, ssecorp wrote:
    I know zip but lets say I have a word "painter" and I want to compare it
    to a customer's spelling, he might have written "paintor" and I want to
    check how many letters are the same.

    Now I know how I could do this, it is not hard. I am just wondering if
    these is any specific simple syntax for it.
    No special syntax for that, but you can combine the `sum()` function, a
    generator expression and `zip()`:

    In [40]: sum(int(a == b) for a, b in zip('painter', 'paintor'))
    Out[40]: 6

    Or this way if you think it's more clear:

    In [41]: sum(1 for a, b in zip('painter', 'paintor') if a == b)
    Out[41]: 6

    Ciao,
    Marc 'BlackJack' Rintsch
    --




    The information contained in this message and any attachment may be
    proprietary, confidential, and privileged or subject to the work
    product doctrine and thus protected from disclosure. If the reader
    of this message is not the intended recipient, or an employee or
    agent responsible for delivering this message to the intended
    recipient, you are hereby notified that any dissemination,
    distribution or copying of this communication is strictly prohibited.
    If you have received this communication in error, please notify me
    immediately by replying to this message and deleting it and all
    copies and backups thereof. Thank you.


  • Casey

    #2
    Re: for x,y in word1, word2 ?

    My first thought is that you should be looking at implementations of
    Hamming Distance. If you are actually looking for something like
    SOUNDEX you might also want to look at the double metaphor algorithm,
    which is significantly harder to implement but provides better
    matching and is less susceptible to differences based on name origins.

    Comment

    • Timothy Grant

      #3
      Re: for x,y in word1, word2 ?

      On Mon, Aug 11, 2008 at 8:44 AM, Casey <Caseyweb@gmail .comwrote:
      My first thought is that you should be looking at implementations of
      Hamming Distance. If you are actually looking for something like
      SOUNDEX you might also want to look at the double metaphor algorithm,
      which is significantly harder to implement but provides better
      matching and is less susceptible to differences based on name origins.
      --

      >
      I responded in the thread of the poster's original message on this
      subject, but will do the same here. I have a horribly ugly version of
      the double-metaphone algorithm in python that does work, and may be of
      some use in solving this problem.

      --
      Stand Fast,
      tjg. [Timothy Grant]

      Comment

      • Dave Webster

        #4
        Re: for x,y in word1, word2 ?

        Thanks, Timothy. I'm pretty sure that there is no such thing as a "beautiful"
        implementation of double-metaphone but I would personally like to have a copy
        of your python implementation. I have a fairly elegant version of the original
        metaphone algorithm I wrote myself (in PERL, many years ago) but I've
        never found
        the time to reverse-engineer the original C++ code for double-metaphone and
        "pythonize" it.

        On Mon, Aug 11, 2008 at 2:08 PM, Timothy Grant <timothy.grant@ gmail.comwrote:
        On Mon, Aug 11, 2008 at 8:44 AM, Casey <Caseyweb@gmail .comwrote:
        >My first thought is that you should be looking at implementations of
        >Hamming Distance. If you are actually looking for something like
        >SOUNDEX you might also want to look at the double metaphor algorithm,
        >which is significantly harder to implement but provides better
        >matching and is less susceptible to differences based on name origins.
        >--
        >http://mail.python.org/mailman/listinfo/python-list
        >>
        >
        I responded in the thread of the poster's original message on this
        subject, but will do the same here. I have a horribly ugly version of
        the double-metaphone algorithm in python that does work, and may be of
        some use in solving this problem.
        >
        --
        Stand Fast,
        tjg. [Timothy Grant]
        >

        Comment

        Working...