Returns a list of token tags parsed from the given element. Tags that are not attributes in a (e.g., relation) can be given as parameters.
(word, chunk="O", pnp="O", relation="O", anchor="O",
format=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA])
| 1453 | return ";".join(["-".join([x for x in (type, r1, r2) if x]) for r1, r2 in zip(r1, r2)]) |
| 1454 | |
| 1455 | def _parse_token(word, chunk="O", pnp="O", relation="O", anchor="O", |
| 1456 | format=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]): |
| 1457 | """ Returns a list of token tags parsed from the given <word> element. |
| 1458 | Tags that are not attributes in a <word> (e.g., relation) can be given as parameters. |
| 1459 | """ |
| 1460 | tags = [] |
| 1461 | for tag in format: |
| 1462 | if tag == WORD : tags.append(xml_decode(word.value)) |
| 1463 | elif tag == POS : tags.append(xml_decode(word.get(XML_TYPE, "O"))) |
| 1464 | elif tag == CHUNK : tags.append(chunk) |
| 1465 | elif tag == PNP : tags.append(pnp) |
| 1466 | elif tag == REL : tags.append(relation) |
| 1467 | elif tag == ANCHOR : tags.append(anchor) |
| 1468 | elif tag == LEMMA : tags.append(xml_decode(word.get(XML_LEMMA, ""))) |
| 1469 | else: |
| 1470 | # Custom tags when the parser has been extended, see also Word.custom_tags{}. |
| 1471 | tags.append(xml_decode(word.get(tag, "O"))) |
| 1472 | return tags |
| 1473 | |
| 1474 | ### NLTK TREE ###################################################################################### |
| 1475 |
no test coverage detected
searching dependent graphs…