John Machin wrote: > On 25/04/2006 6:26 PM, Iain King wrote: > > hawkesed wrote: > >> If I have a list, say of names. And I want to count all the people > >> named, say, Susie, but I don't care exactly how they spell it (ie, > >> Susy, Susi, Susie all work.) how would I do this? Set up a regular > >> expression inside the count? Is there a wildcard variable I can use? > >> Here is the code for the non-fuzzy way: > >> lstNames.count("Susie") > >> Any ideas? Is this something you wouldn't expect count to do? > >> Thanks y'all from a newbie.
snip > > steven = re.compile("Ste(v|ph|f)(e|a)n") > > What about Steffan, Etienne, Esteban, István, ... ? > well, obviously these could be included: "(Ste(v|ph|f)(e|a)n|Steffan|Etienne|Esteban)", but the OP never said he wanted to translate anything into another language. He just wanted to catch variable spellings. > > john = re.compile("Jo(h)?n") > > > > IMHO, the amount of hand-crafting that goes into a *general-purpose* > phonetic matching algorithm is already bordering on overkill. Your > method using REs would not appear to scale well at all. Iain -- http://mail.python.org/mailman/listinfo/python-list