Re: python/regex question... hope someone can help

2007-12-09 Thread Gabriel Genellina
En Sun, 09 Dec 2007 16:45:53 -0300, charonzen <[EMAIL PROTECTED]> escribió: >> [John Machin] Another suggestion is to ensure that the job >> specification is not >> overly simplified. How did you parse the text into "words" in the >> prior exercise that produced the list of bigrams? Won't you

Re: python/regex question... hope someone can help

2007-12-09 Thread charonzen
> Another suggestion is to ensure that the job specification is not > overly simplified. How did you parse the text into "words" in the > prior exercise that produced the list of bigrams? Won't you need to > use the same parsing method in the current exercise of tagging the > bigrams with an under

Re: python/regex question... hope someone can help

2007-12-09 Thread John Machin
On Dec 9, 6:13 pm, charonzen <[EMAIL PROTECTED]> wrote: The following *may* come close to doing what your revised spec requires: import re def ch_replace2(alist, text): for bigram in alist: pattern = r'\b' + bigram.replace('_', ' ') + r'\b' text = re.sub(pattern, bigram, text)

Re: python/regex question... hope someone can help

2007-12-09 Thread John Machin
On Dec 9, 6:13 pm, charonzen <[EMAIL PROTECTED]> wrote: > I have a list of strings. These strings are previously selected > bigrams with underscores between them ('and_the', 'nothing_given', and > so on). I need to write a regex that will read another text string > that this list was derived from

python/regex question... hope someone can help

2007-12-08 Thread charonzen
I have a list of strings. These strings are previously selected bigrams with underscores between them ('and_the', 'nothing_given', and so on). I need to write a regex that will read another text string that this list was derived from and replace selections in this text string with those from my l