rsyntaxtree 2.5.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/CITATION.cff +2 -2
- data/README.md +7 -2
- data/bin/rsyntaxtree +14 -4
- data/lib/rsyntaxtree/base_graph.rb +77 -20
- data/lib/rsyntaxtree/element.rb +126 -20
- data/lib/rsyntaxtree/json_graph.rb +21 -7
- data/lib/rsyntaxtree/markup_parser.rb +23 -5
- data/lib/rsyntaxtree/notation_core.md +19 -5
- data/lib/rsyntaxtree/notation_examples.md +57 -2
- data/lib/rsyntaxtree/string_parser.rb +1 -1
- data/lib/rsyntaxtree/svg_graph.rb +272 -104
- data/lib/rsyntaxtree/tikz_generator.rb +50 -10
- data/lib/rsyntaxtree/utils.rb +5 -2
- data/lib/rsyntaxtree/version.rb +1 -1
- data/lib/rsyntaxtree.rb +91 -12
- metadata +1 -1
|
@@ -27,7 +27,15 @@ figure that was meant.
|
|
|
27
27
|
- A straight apostrophe is typeset as the curly ’ (U+2019); \' keeps it
|
|
28
28
|
straight.
|
|
29
29
|
- A `+` followed by digits at the end of a label is a movement path (+1, +>2).
|
|
30
|
-
\+ is a plus sign, so C\+\+11 and 2\+2 draw as written.
|
|
30
|
+
\+ is a plus sign, so C\+\+11 and 2\+2 draw as written. The markers come
|
|
31
|
+
last, after any coloured stretch: NP\n@gray(note)+>1, not @gray(note+>1).
|
|
32
|
+
- Decorations nest either way round (___*x*___ and *___x___* both draw small
|
|
33
|
+
italic), but a coloured stretch @color(...) goes outside them all:
|
|
34
|
+
@red(**x**), never **@red(x)**.
|
|
35
|
+
- `@` followed by a colour name or #hex and `(` opens a coloured stretch,
|
|
36
|
+
wherever it stands: bob@red(note) draws "bob" and a red "note". Write \@ for
|
|
37
|
+
an @ meant as a character there: mail\@example(x). A stretch holds at least
|
|
38
|
+
one character and closes within its line and its cell: @red(a)\t@red(b).
|
|
31
39
|
- A backslash takes the character after it, whatever it is: \q draws q, and
|
|
32
40
|
C:\path draws C:path. A backslash itself is \\.
|
|
33
41
|
- A program building labels from text it did not choose should not copy
|
|
@@ -54,6 +62,7 @@ Structure:
|
|
|
54
62
|
| an invisible joint, to align leaves | a label of only <>, as in [X [<> [Y y]] [Z z]] |
|
|
55
63
|
| a movement path (dashed) | [S [NP a+1] [VP [V b] [NP c+1]]] |
|
|
56
64
|
| the same, with an arrowhead | write +>1 on the end the arrow points at |
|
|
65
|
+
| a path to a phrase | +1 on a node with daughters: the line stops a clearance outside the phrase and its shade, on the word side |
|
|
57
66
|
| an extra straight connector | +-1 on two nodes; +->1 for an arrowhead |
|
|
58
67
|
|
|
59
68
|
Inside a label:
|
|
@@ -62,7 +71,7 @@ Inside a label:
|
|
|
62
71
|
|----------------------------------------|-------------------|
|
|
63
72
|
| italic, bold, both | *x*, **x**, ***x*** |
|
|
64
73
|
| subscript, superscript | x_i_, x__2__ |
|
|
65
|
-
| small
|
|
74
|
+
| smaller type (70%), as for small caps | H___EAD___ — on lower case it is simply smaller: ___*a<>note*___ |
|
|
66
75
|
| overline, underline, strikethrough | =x=, -x-, ~x~ |
|
|
67
76
|
| a line break; a blank line | a\nb (or a\ b); \n\n |
|
|
68
77
|
| columns, aligned down the label | HEAD\t*verb*\nSPR\t⟨<>⟩ |
|
|
@@ -80,6 +89,8 @@ Around a label:
|
|
|
80
89
|
| a whole label that is one matrix | [#(CAT\tS#) [#(CAT\tNP#) Kim] [#(CAT\tVP#) sleeps]] |
|
|
81
90
|
| a region shade behind the subtree | %NP, coloured: %@blue:NP |
|
|
82
91
|
| a colour | @red:NP, @#3af:NP, @#33aaff:NP (3 or 6 hex digits) |
|
|
92
|
+
| part of a label in colour | look @red(at) the chickens, @#3af({}->) — within one line, outside other markup; \) for a ')' inside |
|
|
93
|
+
| a note under a category | [NP\n@gray(___*causer*___) Pat] — small grey italic on the label's second line |
|
|
83
94
|
|
|
84
95
|
An attribute-value matrix is columns plus an enclosure, and a value can be
|
|
85
96
|
another matrix — nested with #( ... #), never with square brackets, which are
|
|
@@ -99,10 +110,10 @@ Options (the command line spells them --like-this):
|
|
|
99
110
|
| fontsize | 6–26 |
|
|
100
111
|
| color | modern, traditional, off, gray |
|
|
101
112
|
| linewidth | every line's weight, 0.5–3.0, as a ratio of the font size |
|
|
102
|
-
| leafstyle | auto, bar, nothing — what joins a node to its leaf |
|
|
113
|
+
| leafstyle | auto, bar, dashed, nothing — what joins a node to its leaf |
|
|
103
114
|
| direction | ttb, ltr, btt |
|
|
104
|
-
| mirror | flip the finished layout, for RTL scripts |
|
|
105
|
-
| tidy | off, symmetric, low, medium, high — how tightly subtrees pack |
|
|
115
|
+
| mirror | flip the finished layout, for RTL scripts; not with direction ltr |
|
|
116
|
+
| tidy | off, symmetric, low, medium, high — how tightly subtrees pack; the packing modes leave the column under a movement path's end clear, which can widen a figure |
|
|
106
117
|
| hspacing | how far apart sisters sit, 0.5–3.0 |
|
|
107
118
|
| vheight | how far apart levels sit, 0.5–5.0 |
|
|
108
119
|
| polyline | draw each connector as two right angles rather than a slanted line |
|
|
@@ -114,6 +125,9 @@ Options (the command line spells them --like-this):
|
|
|
114
125
|
| shear | tilt the drawn figure: degrees, −45 to 45, positive leans the top right |
|
|
115
126
|
| shear_plane | the plane behind a sheared figure: on (grey), off, or a colour; never drawn on a transparent background |
|
|
116
127
|
| vmargin | clearance between a label and its connectors, 0.1–1.0, the same above and below |
|
|
128
|
+
| corner_label | a short string set in a corner of the image beside the tree, written as is (no markup) — a judgement mark such as * or ?? |
|
|
129
|
+
| corner_label_position | top-left, top-right, bottom-left, bottom-right |
|
|
130
|
+
| corner_label_size, corner_label_color, corner_label_fontstyle | 6–52 (1.5 × fontsize unless given), a colour name or hex (black unless given), a font style (fontstyle unless given) |
|
|
117
131
|
|
|
118
132
|
hspacing and vheight are named for the top-to-bottom layout, and follow the
|
|
119
133
|
tree rather than the page: with direction ltr, sisters stack downwards and
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
RSyntaxTree examples:
|
|
1
|
+
RSyntaxTree examples: 85 trees, every one verified to draw.
|
|
2
2
|
|
|
3
3
|
Each is the input behind a figure in the gallery at https://yohasebe.github.io/rsyntaxtree/examples.
|
|
4
4
|
The settings line names the options the gallery records for that figure;
|
|
@@ -2488,7 +2488,7 @@ own(x,<>y)
|
|
|
2488
2488
|
]
|
|
2489
2489
|
```
|
|
2490
2490
|
|
|
2491
|
-
## 080 — Terminals levelled with pass-through joints
|
|
2491
|
+
## 080 — Terminals levelled by hand with pass-through joints
|
|
2492
2492
|
|
|
2493
2493
|
Category: General
|
|
2494
2494
|
Settings: fontstyle=noto-serif tidy=low vheight=1.0
|
|
@@ -2639,3 +2639,58 @@ SYN\t#(HEAD\t|1|#)#)
|
|
|
2639
2639
|
---\
|
|
2640
2640
|
AGR\t|2|#)#)#) [bark]]]
|
|
2641
2641
|
```
|
|
2642
|
+
|
|
2643
|
+
## 087 — Terminals levelled automatically: whole subtrees drop
|
|
2644
|
+
|
|
2645
|
+
Category: General
|
|
2646
|
+
Settings: fontstyle=noto-serif leaf_align=subtrees polyline=on tidy=low vheight=1.0
|
|
2647
|
+
|
|
2648
|
+
```
|
|
2649
|
+
[S
|
|
2650
|
+
[NP [D the] [N cat]]
|
|
2651
|
+
[VP
|
|
2652
|
+
[V sat]
|
|
2653
|
+
[PP [P on] [NP [D the] [N mat]]]]]
|
|
2654
|
+
```
|
|
2655
|
+
|
|
2656
|
+
## 088 — Wh-movement with the terminals levelled
|
|
2657
|
+
|
|
2658
|
+
Category: Generative Grammar
|
|
2659
|
+
Settings: fontstyle=noto-serif leaf_align=subtrees polyline=on tidy=low vheight=1.0
|
|
2660
|
+
|
|
2661
|
+
```
|
|
2662
|
+
[CP
|
|
2663
|
+
[DP what+>1]
|
|
2664
|
+
[C' [C did]
|
|
2665
|
+
[TP
|
|
2666
|
+
[DP [D the] [NP [N child]]]
|
|
2667
|
+
[T' [T t]
|
|
2668
|
+
[VP [V find] [DP t+1]]]]]]
|
|
2669
|
+
```
|
|
2670
|
+
|
|
2671
|
+
## 089 — A Japanese sentence with its words on one row
|
|
2672
|
+
|
|
2673
|
+
Category: Multilingual
|
|
2674
|
+
Settings: fontstyle=noto-serif leaf_align=words leafstyle=dashed tidy=low vheight=1.0
|
|
2675
|
+
|
|
2676
|
+
```
|
|
2677
|
+
[S
|
|
2678
|
+
[NP [N 太郎] [P が]]
|
|
2679
|
+
[VP
|
|
2680
|
+
[NP [AdjP [Adj 古い]] [NP [N 本] [P を]]]
|
|
2681
|
+
[V 読んだ]]]
|
|
2682
|
+
```
|
|
2683
|
+
|
|
2684
|
+
## 090 — A summarised phrase deep in the tree, with the terminals levelled
|
|
2685
|
+
|
|
2686
|
+
Category: General
|
|
2687
|
+
Settings: fontstyle=noto-serif leaf_align=words leafstyle=dashed tidy=low vheight=1.0
|
|
2688
|
+
|
|
2689
|
+
```
|
|
2690
|
+
[TP
|
|
2691
|
+
[DP [D the]
|
|
2692
|
+
[NP [N man]
|
|
2693
|
+
[PP [P with] [^DP the hat]]]]
|
|
2694
|
+
[T' [T will]
|
|
2695
|
+
[VP [V give] [DP [D the] [NP [N book]]]]]]
|
|
2696
|
+
```
|
|
@@ -256,7 +256,7 @@ module RSyntaxTree
|
|
|
256
256
|
# `\#` arrived at the grammar as a bare '#', which opens an enclosure,
|
|
257
257
|
# so a label written with a hash in it lost the hash and everything
|
|
258
258
|
# after it went inside brackets instead.
|
|
259
|
-
when /[nt{}<>^+*_=~|%\-#@']/
|
|
259
|
+
when /[nt{}<>^+*_=~|%\-#@'()]/
|
|
260
260
|
if escape
|
|
261
261
|
token += '\\' + ch
|
|
262
262
|
escape = false
|