473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Re: for x,y in word1, word2 ?

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

regards
Edwin

-----Original Message-----
From: py************************************************ **@python.org
[mailto:py***************************************** *********@python.org]
On Behalf Of Marc 'BlackJack' Rintsch
Sent: Monday, August 11, 2008 3:09 AM
To: py*********@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
--
http://mail.python.org/mailman/listinfo/python-list

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.
Aug 11 '08 #1
3 2037
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.
Aug 11 '08 #2
On Mon, Aug 11, 2008 at 8:44 AM, Casey <Ca******@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]
Aug 11 '08 #3
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 <ti***********@gmail.comwrote:
On Mon, Aug 11, 2008 at 8:44 AM, Casey <Ca******@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]
Aug 11 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PM | last post by:
I'm trying to make a kind of search history containing the 3 last searched words. So I'm using 3 Session Variables: Word1 / Word2 / Word3. In order to get this history working, I need to put the...
9
by: Nathan Sokalski | last post by:
I am trying to do a database search using LIKE using the following code: Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click If...
7
by: Ron | last post by:
I have a couple of questions about this class.....: Public Class WordPair Private word1 As String Private word2 As String Public Sub New() word1 = "" word2 = "" End Sub Public Sub New(ByVal...
11
by: Flyzone | last post by:
Hello, i have again problem with regexp :-P I need to match all lines that contain one word but not contain another. Like to do "grep one | grep -v two:" The syntax of the string is: (any...
6
by: logieen | last post by:
Hi , Every one I really need some help in my programs it doesn't work as I want I know there something wrong in it if you know where the wrong is just show me plz as soon as Possible plzzzzz. I a...
11
by: captainphoenix | last post by:
In VB (.NET?) building a query from a table made in MS Access. I'm trying to type the sql line WHERE = @ but it won't recognize the code because "Course Number" is two words. the whole thing...
7
by: ssecorp | last post by:
Is there a syntax for looping through 2 iterables at the same time? for x in y: for a in b: is not what I want. I want: for x in y and for a in b:
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.