| 1303 | # s = Text(s, token=[WORD, POS, CHUNK, PNP, LEMMA]) # (1) |
| 1304 | |
| 1305 | class XML(object): |
| 1306 | def __init__(self, string): |
| 1307 | from xml.etree import cElementTree |
| 1308 | self.root = cElementTree.fromstring(string) |
| 1309 | def __call__(self, tag): |
| 1310 | return [XMLNode(e) for e in self.root.findall(tag)] |
| 1311 | |
| 1312 | class XMLNode(object): |
| 1313 | def __init__(self, element): |