rsyntaxtree 1.11.0 → 1.12.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 +30 -0
- data/Rakefile +8 -0
- data/bin/rsyntaxtree +16 -5
- data/lib/rsyntaxtree/element.rb +4 -4
- data/lib/rsyntaxtree/notation_core.md +7 -7
- data/lib/rsyntaxtree/notation_examples.md +2536 -0
- data/lib/rsyntaxtree/version.rb +1 -1
- data/lib/rsyntaxtree.rb +8 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 160b79f9047cb7674fe1c980dcf9e1a4044ca2c68eb3c758eabc9389d73d829a
|
|
4
|
+
data.tar.gz: 648c5297ccfbaefde5c2904cc5266ed56207487bc6ac64320041ac7e135e4814
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5465a152a7de5a453731cee9595f5d98636640fc8f97f7a21320e3ac66d14cf9876c10941518f936b586e0e6613944c2eb6e05175b6740a49aab544c97008e54
|
|
7
|
+
data.tar.gz: 78c83cee893a040d10959508199f354d3c568aa2a65fcba7bb486ddce6839314f6fcbd7d094c759804a77df07df660811508949ab7ffb9a9a7e81559e0e85b89
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.12.0] - 2026-08
|
|
4
|
+
|
|
5
|
+
Everything needed to write this notation is now available as text, built from
|
|
6
|
+
the files the tool itself reads, and a refusal says where that text is.
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- `--examples` prints every published example with the options it was drawn
|
|
10
|
+
with. The gallery examples are checked against the parser that draws them,
|
|
11
|
+
so each one is known to be accepted.
|
|
12
|
+
- The site carries the same material as plain text for a reader that can fetch
|
|
13
|
+
a URL but cannot run a command: `llms.txt` and `llms-full.txt`, the second
|
|
14
|
+
holding the reference, the manual and every example in one file. Both are
|
|
15
|
+
generated from their sources, and a test fails if they fall behind.
|
|
16
|
+
- A refusal names where the notation is written down, once, alongside the
|
|
17
|
+
cause and the fix. A hint repairs the mistake in front of it and says
|
|
18
|
+
nothing about the rest, which is not enough for a caller that was guessing.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- The angle bracket the reference recommends is U+27E8 and U+27E9, which it
|
|
22
|
+
had always named while writing U+3008 and U+3009 in its own examples. The
|
|
23
|
+
East Asian pair draws a full em wide, wider than a capital, and had spread
|
|
24
|
+
through the gallery and into the repair that corrects ASCII brackets. Both
|
|
25
|
+
pairs still parse; documents written before this are unaffected.
|
|
26
|
+
- Two feature-structure figures are redrawn at the narrower bracket.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- `--notation` and `--examples` answer before the input is read. Reading first
|
|
30
|
+
meant waiting on a pipe that never closes when stdin is not a terminal,
|
|
31
|
+
which is how a script reaches them.
|
|
32
|
+
|
|
3
33
|
## [1.11.0] - 2026-08
|
|
4
34
|
|
|
5
35
|
Every input the tool accepts now draws, and every input it refuses says why.
|
data/Rakefile
CHANGED
|
@@ -42,6 +42,14 @@ task :generate do
|
|
|
42
42
|
require_relative "dev/generate_examples"
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
# What a language model is given: the reference, the manual and every example,
|
|
46
|
+
# built from the files those already live in. Run it after changing any of
|
|
47
|
+
# them; llm_payload_test.rb fails if the built files are out of date.
|
|
48
|
+
desc "Build the notation payload for language models (gem and site)"
|
|
49
|
+
task :llm_payload do
|
|
50
|
+
ruby "dev/generate_llm_payload.rb"
|
|
51
|
+
end
|
|
52
|
+
|
|
45
53
|
desc "Record the pixel size of each gallery figure for the examples page"
|
|
46
54
|
task :figure_sizes do
|
|
47
55
|
ruby "dev/stamp_figure_sizes.rb"
|
data/bin/rsyntaxtree
CHANGED
|
@@ -126,6 +126,7 @@ opts = Optimist.options do
|
|
|
126
126
|
opt :hyphen, "How a hyphen in a label reads: markup (-underline-) or literal (a hyphen; \-underline\- then underlines)", default: "markup", short: :none
|
|
127
127
|
opt :validate, "Validate the input without drawing or writing a file: print a machine-readable diagnosis (JSON) to stdout and report the result in the exit code", short: :none
|
|
128
128
|
opt :notation, "Print the notation reference to stdout and exit", short: :none
|
|
129
|
+
opt :examples, "Print every gallery example, with the options each needs, to stdout and exit", short: :none
|
|
129
130
|
opt :help, "This is a custom help message", short: :h
|
|
130
131
|
end
|
|
131
132
|
|
|
@@ -171,6 +172,21 @@ if %w[jpg gif].include?(string_opts[:format])
|
|
|
171
172
|
warn "Warning: #{string_opts[:format].upcase} output is deprecated and will be removed in RSyntaxTree 2.0. Use PNG instead."
|
|
172
173
|
end
|
|
173
174
|
|
|
175
|
+
# These print and exit, so they answer before the input is read. Reading
|
|
176
|
+
# first meant waiting on a pipe that never closes when stdin is not a
|
|
177
|
+
# terminal, which is how they are reached from a script.
|
|
178
|
+
if opts[:notation]
|
|
179
|
+
puts File.read(File.expand_path("../lib/rsyntaxtree/notation_core.md", __dir__))
|
|
180
|
+
exit 0
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# The examples are the reference's counterpart: the rules in brief there, and
|
|
184
|
+
# here every published tree with the options it was drawn with.
|
|
185
|
+
if opts[:examples]
|
|
186
|
+
puts File.read(File.expand_path("../lib/rsyntaxtree/notation_examples.md", __dir__))
|
|
187
|
+
exit 0
|
|
188
|
+
end
|
|
189
|
+
|
|
174
190
|
# An argument names a file only if it really is one: File.exist? on an
|
|
175
191
|
# expanded empty string answers for the current directory, and reading that
|
|
176
192
|
# as the tree ended the run with a Ruby error.
|
|
@@ -187,11 +203,6 @@ data = if ARGV[0] && !ARGV[0].empty? && File.file?(File.expand_path(ARGV[0]))
|
|
|
187
203
|
# Auto-convert Penn TreeBank format to bracket notation
|
|
188
204
|
data = RSyntaxTree::FormatConverter.to_bracket(data) if data
|
|
189
205
|
|
|
190
|
-
if opts[:notation]
|
|
191
|
-
puts File.read(File.expand_path("../lib/rsyntaxtree/notation_core.md", __dir__))
|
|
192
|
-
exit 0
|
|
193
|
-
end
|
|
194
|
-
|
|
195
206
|
# Validate without drawing or writing anything: the diagnosis goes to stdout
|
|
196
207
|
# as JSON and the exit code carries the verdict.
|
|
197
208
|
if opts[:validate]
|
data/lib/rsyntaxtree/element.rb
CHANGED
|
@@ -133,8 +133,8 @@ module RSyntaxTree
|
|
|
133
133
|
->(s) { s.sub(/\A%?@(?:#[0-9a-zA-Z]+|[a-zA-Z]+)?:/, "") },
|
|
134
134
|
"A color is @name: with a CSS color name, or @#rgb: / @#rrggbb: with 3 or 6 hex digits (e.g. @blue:VP, @#3af:VP)."],
|
|
135
135
|
[:angle_brackets,
|
|
136
|
-
->(s) { s.gsub(/(?<!\\)<([^<>]*[^<>\d][^<>]*)>/) { "
|
|
137
|
-
"'<' and '>' mark whitespace here, not a list. Write the angle bracket characters themselves:
|
|
136
|
+
->(s) { s.gsub(/(?<!\\)<([^<>]*[^<>\d][^<>]*)>/) { "⟨#{$1}⟩" } },
|
|
137
|
+
"'<' and '>' mark whitespace here, not a list. Write the angle bracket characters themselves: ⟨NP⟩, 'hand⟨SUBJ,OBJ⟩'."],
|
|
138
138
|
[:bare_hyphen,
|
|
139
139
|
->(s) { Element.escape_hyphens(s) },
|
|
140
140
|
"A hyphen opens an underline. Escape it (e.g. f\\-structure, V\\-bar) or set the hyphen option to literal."],
|
|
@@ -175,7 +175,7 @@ module RSyntaxTree
|
|
|
175
175
|
# away, one of them starting the split and the next ending it.
|
|
176
176
|
if label.strip.empty?
|
|
177
177
|
return details.merge(code: :label_split,
|
|
178
|
-
hint: "Raw spaces left this label empty. Write a space inside a label as <> (e.g.
|
|
178
|
+
hint: "Raw spaces left this label empty. Write a space inside a label as <> (e.g. ⟨<>NP<>⟩).",
|
|
179
179
|
retryable: true)
|
|
180
180
|
end
|
|
181
181
|
|
|
@@ -195,7 +195,7 @@ module RSyntaxTree
|
|
|
195
195
|
# a hint that admits no one cause was found rather than naming a wrong
|
|
196
196
|
# one. retryable: false is for what no rewriting reaches.
|
|
197
197
|
details.merge(code: :invalid_markup,
|
|
198
|
-
hint: "No single cause fits, which usually means more than one mistake in this label. Check that *, _, =, ~, |, { and #(...#) are paired, that hyphens are escaped, and that
|
|
198
|
+
hint: "No single cause fits, which usually means more than one mistake in this label. Check that *, _, =, ~, |, { and #(...#) are paired, that hyphens are escaped, and that ⟨ ⟩ are the angle bracket characters.",
|
|
199
199
|
retryable: true)
|
|
200
200
|
end
|
|
201
201
|
|
|
@@ -16,10 +16,10 @@ Within a label:
|
|
|
16
16
|
|
|
17
17
|
Four traps, because these characters already mean something:
|
|
18
18
|
- `<` and `>` are never angle brackets in this notation: `<>` is one space,
|
|
19
|
-
`<3>` is three. Wherever linguistics uses angle brackets — a list
|
|
20
|
-
an argument structure like 'hand
|
|
21
|
-
characters
|
|
22
|
-
SPR\t
|
|
19
|
+
`<3>` is three. Wherever linguistics uses angle brackets — a list ⟨NP⟩,
|
|
20
|
+
an argument structure like 'hand⟨SUBJ,OBJ⟩', anything — write the
|
|
21
|
+
characters ⟨ and ⟩ themselves (U+27E8 and U+27E9):
|
|
22
|
+
SPR\t⟨<>NP<>⟩ PRED\t'hand⟨SUBJ,OBJ⟩'
|
|
23
23
|
- `-` opens and closes an underline, so a bare hyphen in ANY word is an
|
|
24
24
|
error: V-bar, f-structure, HEAD-DTR. Write `V'`, or escape the hyphen:
|
|
25
25
|
`V\-bar`, `f\-structure`, `HEAD\-DTR`.
|
|
@@ -35,14 +35,14 @@ An attribute-value matrix is columns plus an enclosure:
|
|
|
35
35
|
|
|
36
36
|
[#*word*\
|
|
37
37
|
HEAD\t*verb*\
|
|
38
|
-
SPR\t
|
|
39
|
-
COMPS\t
|
|
38
|
+
SPR\t⟨<>NP<>⟩\
|
|
39
|
+
COMPS\t⟨<>⟩
|
|
40
40
|
]
|
|
41
41
|
|
|
42
42
|
A value can be another matrix. Nest it with `#( ... #)`, never with square
|
|
43
43
|
brackets — those are read as tree structure:
|
|
44
44
|
|
|
45
|
-
[#PRED\t'hand
|
|
45
|
+
[#PRED\t'hand⟨SUBJ,OBJ⟩'\
|
|
46
46
|
TENSE\tpast\
|
|
47
47
|
SUBJ\t#(PRED\t'David'#)
|
|
48
48
|
]
|