A quiestion from a mx.TextTools newbie

Wenping Wang <wenping0-/[email protected]>
Newsgroups gmane.comp.python.egenix.user
Message-ID <[email protected]>
Hello Friends,

I'm new to mx.TextTools & am learning this powerful tool by reading David Mertz's excellent book "Text Processing in Python".  Naturally I tried the examples in the book.  One particular example concerning mx.TextTools is the one under "mx.TextTools.AppendTagobj" on Page 307.

Unfortunately, that example from David's book doesn't work.  I was able to tweak the code to make it work.  But I was puzzled why it doesn't work.  I attach the segment of codes here.

#--- example code starts
from mx.TextTools import *

#--- 1st approach: failure
words = (('word', AllIn+AppendTagobj, alpha),
(None, AllIn, whitespace, MatchFail, -1))
tag('this and that', words)

#--- 2nd approach: success
words = (('word', AllIn, alpha),
(None, AllIn, whitespace, +1),
(None,EOF,Here,-2))
tag('this and that', words)

#--- 3rd approach: success
word = []
def emiter(tl,txt,l,r,s):
    word.append(txt[l:r])

words = ((emiter, AllIn+CallTag, alpha),
(None, AllIn, whitespace, MatchFail, -1))
tag('this and that', words)
#--- example code ends

Can someone provide me some insight why the 1st approach doesn't work while the 2nd & 3rd work?  BTW, I'm using mx.TextTools 3.1.2 on Windows.

Thanks much.

Best,
Wenping Wang


_______________________________________________________________________
eGenix.com User Mailing List                     http://www.egenix.com/
https://www.egenix.com/mailman/listinfo/egenix-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.