|
20 | 20 | class TextModeTrees(BaseWriter): |
21 | 21 | """An ASCII pretty printer of dependency trees. |
22 | 22 |
|
23 | | - SYNOPSIS |
24 | | - # from command line (visualize CoNLL-U files) |
25 | | - udapy write.TextModeTrees color=1 < file.conllu | less -R |
| 23 | + .. code-block:: bash |
26 | 24 |
|
27 | | - # is scenario (examples of other parameters) |
28 | | - write.TextModeTrees indent=1 print_sent_id=1 print_sentence=1 |
29 | | - write.TextModeTrees zones=en,cs attributes=form,lemma,upos minimize_cross=0 |
| 25 | + # from the command line (visualize CoNLL-U files) |
| 26 | + udapy write.TextModeTrees color=1 < file.conllu | less -R |
| 27 | +
|
| 28 | + In scenario (examples of other parameters):: |
| 29 | +
|
| 30 | + write.TextModeTrees indent=1 print_sent_id=1 print_sentence=1 |
| 31 | + write.TextModeTrees zones=en,cs attributes=form,lemma,upos minimize_cross=0 |
30 | 32 |
|
31 | | - DESCRIPTION |
32 | 33 | This block prints dependency trees in plain-text format. |
33 | | - For example the following CoNLL-U file (with tabs instead of spaces) |
34 | | -
|
35 | | - 1 I I PRON PRP Number=Sing|Person=1 2 nsubj _ _ |
36 | | - 2 saw see VERB VBD Tense=Past 0 root _ _ |
37 | | - 3 a a DET DT Definite=Ind 4 det _ _ |
38 | | - 4 dog dog NOUN NN Number=Sing 2 dobj _ _ |
39 | | - 5 today today NOUN NN Number=Sing 2 nmod:tmod _ SpaceAfter=No |
40 | | - 6 , , PUNCT , _ 2 punct _ _ |
41 | | - 7 which which DET WDT PronType=Rel 10 nsubj _ _ |
42 | | - 8 was be VERB VBD Person=3|Tense=Past 10 cop _ _ |
43 | | - 9 a a DET DT Definite=Ind 10 det _ _ |
44 | | - 10 boxer boxer NOUN NN Number=Sing 4 acl:relcl _ SpaceAfter=No |
45 | | - 11 . . PUNCT . _ 2 punct _ _ |
46 | | -
|
47 | | - will be printed (with the default parameters) as |
48 | | - ─┮ |
49 | | - │ ╭─╼ I PRON nsubj |
50 | | - ╰─┾ saw VERB root |
51 | | - │ ╭─╼ a DET det |
52 | | - ├────────────────────────┾ dog NOUN dobj |
53 | | - ├─╼ today NOUN nmod:tmod │ |
54 | | - ├─╼ , PUNCT punct │ |
55 | | - │ │ ╭─╼ which DET nsubj |
56 | | - │ │ ├─╼ was VERB cop |
57 | | - │ │ ├─╼ a DET det |
58 | | - │ ╰─┶ boxer NOUN acl:relcl |
59 | | - ╰─╼ . PUNCT punct |
| 34 | + For example the following CoNLL-U file (with tabs instead of spaces):: |
| 35 | +
|
| 36 | + 1 I I PRON PRP Number=Sing|Person=1 2 nsubj _ _ |
| 37 | + 2 saw see VERB VBD Tense=Past 0 root _ _ |
| 38 | + 3 a a DET DT Definite=Ind 4 det _ _ |
| 39 | + 4 dog dog NOUN NN Number=Sing 2 dobj _ _ |
| 40 | + 5 today today NOUN NN Number=Sing 2 nmod:tmod _ SpaceAfter=No |
| 41 | + 6 , , PUNCT , _ 2 punct _ _ |
| 42 | + 7 which which DET WDT PronType=Rel 10 nsubj _ _ |
| 43 | + 8 was be VERB VBD Person=3|Tense=Past 10 cop _ _ |
| 44 | + 9 a a DET DT Definite=Ind 10 det _ _ |
| 45 | + 10 boxer boxer NOUN NN Number=Sing 4 acl:relcl _ SpaceAfter=No |
| 46 | + 11 . . PUNCT . _ 2 punct _ _ |
| 47 | +
|
| 48 | + will be printed (with the default parameters) as:: |
| 49 | +
|
| 50 | + ─┮ |
| 51 | + │ ╭─╼ I PRON nsubj |
| 52 | + ╰─┾ saw VERB root |
| 53 | + │ ╭─╼ a DET det |
| 54 | + ├────────────────────────┾ dog NOUN dobj |
| 55 | + ├─╼ today NOUN nmod:tmod │ |
| 56 | + ├─╼ , PUNCT punct │ |
| 57 | + │ │ ╭─╼ which DET nsubj |
| 58 | + │ │ ├─╼ was VERB cop |
| 59 | + │ │ ├─╼ a DET det |
| 60 | + │ ╰─┶ boxer NOUN acl:relcl |
| 61 | + ╰─╼ . PUNCT punct |
60 | 62 |
|
61 | 63 | Some non-projective trees cannot be printed witout crossing edges. |
62 | | - TextModeTrees uses a special "bridge" symbol ─╪─ to mark this: |
63 | | - ─┮ |
64 | | - │ ╭─╼ 1 |
65 | | - ├─╪───┮ 2 |
66 | | - ╰─┶ 3 │ |
67 | | - ╰─╼ 4 |
68 | | -
|
69 | | - By default parameter `color=auto`, so if the output is printed to the console |
| 64 | + TextModeTrees uses a special "bridge" symbol ─╪─ to mark this:: |
| 65 | +
|
| 66 | + ─┮ |
| 67 | + │ ╭─╼ 1 |
| 68 | + ├─╪───┮ 2 |
| 69 | + ╰─┶ 3 │ |
| 70 | + ╰─╼ 4 |
| 71 | +
|
| 72 | + By default parameter ``color=auto``, so if the output is printed to the console |
70 | 73 | (not file or pipe), each node attribute is printed in different color. |
71 | 74 | If a given node's MISC contains any of `ToDo`, `Bug` or `Mark` attributes |
72 | 75 | (or any other specified in the parameter `mark`), the node will be highlighted |
73 | 76 | (by reveresing the background and foreground colors). |
74 | 77 |
|
75 | 78 | This block's method `process_tree` can be called on any node (not only root), |
76 | | - which is useful for printing subtrees using `node.print_subtree()`, |
| 79 | + which is useful for printing subtrees using ``node.print_subtree()``, |
77 | 80 | which is internally implemented using this block. |
78 | 81 |
|
79 | 82 | SEE ALSO |
80 | | - `write.TextModeTreesHtml` |
| 83 | + :py:class:`.TextModeTreesHtml` |
81 | 84 | """ |
82 | 85 |
|
83 | 86 | def __init__(self, print_sent_id=True, print_text=True, add_empty_line=True, indent=1, |
|
0 commit comments