| 1585 | tags = [WORD, POS, IOB, CHUNK, ROLE, REL, PNP, ANCHOR, LEMMA] |
| 1586 | tags += [tag for tag in sentence.token if tag not in tags] |
| 1587 | def format(token, tag): |
| 1588 | # Returns the token tag as a string. |
| 1589 | if tag == WORD : s = token.string |
| 1590 | elif tag == POS : s = token.type |
| 1591 | elif tag == IOB : s = token.chunk and (token.index == token.chunk.start and "B" or "I") |
| 1592 | elif tag == CHUNK : s = token.chunk and token.chunk.type |
| 1593 | elif tag == ROLE : s = token.chunk and token.chunk.role |
| 1594 | elif tag == REL : s = token.chunk and token.chunk.relation and str(token.chunk.relation) |
| 1595 | elif tag == PNP : s = token.chunk and token.chunk.pnp and token.chunk.pnp.type |
| 1596 | elif tag == ANCHOR : s = token.chunk and token.chunk.anchor_id |
| 1597 | elif tag == LEMMA : s = token.lemma |
| 1598 | else : s = token.custom_tags.get(tag) |
| 1599 | return s or placeholder |
| 1600 | def outline(column, fill=1, padding=3, align="left"): |
| 1601 | # Add spaces to each string in the column so they line out to the highest width. |
| 1602 | n = max([len(x) for x in column]+[fill]) |