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
> 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
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)
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
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