Re: Help: Creating condensed expressions

2006-03-24 Thread Michael Spencer
[EMAIL PROTECTED] wrote: > Nevermind, I didn't understand the problem/question... Sorry. > > Bye, > bearophile > Really? Your solution looks fine to me. In any case, here's an alternative approach to the (based on the same understanding of the problem as bearophile's, but with the additional

Re: Help: Creating condensed expressions

2006-03-24 Thread Eddie Corns
David Hirschfield <[EMAIL PROTECTED]> writes: >Here's the problem: Given a list of item names like: >apple1 >apple2 >apple3_SD >formA >formB >formC >kla_MM >kla_MB >kca_MM >which is a subset of a much larger list of items, >is there an efficient algorithm to create condensed forms that match >t

Re: Help: Creating condensed expressions

2006-03-24 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Nevermind, I didn't understand the problem/question... Sorry. actually, I think *you* got it right. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help: Creating condensed expressions

2006-03-24 Thread bearophileHUGS
Nevermind, I didn't understand the problem/question... Sorry. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Help: Creating condensed expressions

2006-03-24 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : > David Hirschfield a écrit : > >> Here's the problem: (snip) >> >> is there an efficient algorithm to create condensed forms that match >> those items, Sorry, answered to fast... Well, at least you have a way to test the algo !-) -- http://mail.python.org/mailm

Re: Help: Creating condensed expressions

2006-03-24 Thread Bruno Desthuilliers
David Hirschfield a écrit : > Here's the problem: Given a list of item names like: > > apple1 > apple2 > apple3_SD > formA > formB > formC > kla_MM > kla_MB > kca_MM > > which is a subset of a much larger list of items, > is there an efficient algorithm to create condensed forms that match > tho

Re: Help: Creating condensed expressions

2006-03-24 Thread bearophileHUGS
This is a first try, is something like this enough for you? data = """apple1 apple2 apple3_SD formA formB formC kla_MM kla_MB kca_MM""".split() headtails = {} for word in data: head = word[:-1] if head in headtails: headtails[head].append(word[-1]) else: headtails[hea

Help: Creating condensed expressions

2006-03-24 Thread David Hirschfield
Here's the problem: Given a list of item names like: apple1 apple2 apple3_SD formA formB formC kla_MM kla_MB kca_MM which is a subset of a much larger list of items, is there an efficient algorithm to create condensed forms that match those items, and only those items? Such as: apple[12] apple3