rsyntaxtree 1.13.0 → 1.13.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32cc6cec6f19c5fe62dc9a6de16493d6db35680f72e40b6bbd36f0b1e98add96
4
- data.tar.gz: b6f928fd6919bb289765fac684ae3e98f7988103985deebcb6f73e7f8836e939
3
+ metadata.gz: '0804e9119e0ebb089b4109ae05c9353180362bd6e86fddbf2e4da00db3b08e18'
4
+ data.tar.gz: '01867ffda61d7f81fd3d81a9f6ad44ba83eda4f7d89d1b3b05d53b196bc23fa1'
5
5
  SHA512:
6
- metadata.gz: 50d8b1e91e3c71286406bf45e5e5cdeb2d8170f98a513a6662f0b593a7e077b7af2650057e6d9670469ed937b6ddc7c0073868df6833721c2ba3c81a8f691c46
7
- data.tar.gz: 92df8d83ddbabcdd3cbeaa30f26868da4a13c168d5f97600475f552a197f7ebba70a80cc6ab272f98e2a68c1b8bd9d9a9094d3b01235ec556790f4a944337fee
6
+ metadata.gz: 990e4522fe0e0694d009eddebc2b3b2af98e5beda1f3e2daf9fbf1250199cef31b981215d1ae7db3b711d0030826e2445c7011f427223f8e081bffb8d76451ae
7
+ data.tar.gz: fe620d8c1fe64c289b18d853d6663ceaae5ea8a7486a5f0cf0ce578f8c0e9073e48251f0d7a933d0c7afa9ee7fce896dd6cbf00f3499c8d5314278e9cc0e0b57
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.13.1] - 2026-08
4
+
5
+ ### Fixed
6
+ - `^` at the head of a leaf draws the triangle it asks for. The mark may be
7
+ written on the node's label or on the leaf's own text — `[^NP cats]` and
8
+ `[NP ^cats]` — and the documentation, the notation reference and the gallery
9
+ all use both, but only the first was drawn: the second lost its caret to the
10
+ parser and then a bar was drawn under it. The two now produce the same figure
11
+ in every connector style, and LSIF records the edge as a triangle. Three
12
+ gallery figures change accordingly, each toward what it was written to show.
13
+ - An option given as an empty string is read as an option not given, rather
14
+ than as a value no list contains. An HTML form posts a field for every
15
+ control it carries, and a control with nothing selected posts the empty
16
+ string, so a form that has outlived one of its own controls sends that field
17
+ empty alongside the rest. Since option validation arrived in 1.11.0 that
18
+ failed the whole request: the web UI's Download buttons answered 500 for
19
+ every input, because the form still read a `format` select the page no longer
20
+ had. A value that is actually wrong is still rejected.
21
+
3
22
  ## [1.13.0] - 2026-08
4
23
 
5
24
  ### Added
@@ -221,7 +221,12 @@ module RSyntaxTree
221
221
  else
222
222
  parent = @element_list.get_id(target.parent)
223
223
 
224
- vertical_indent = if !target.triangle &&
224
+ # A leaf with nothing drawn over it is pulled up against its node; one
225
+ # with a triangle over it needs the room the triangle takes. Which is
226
+ # which is the same question the connector asks, so it is asked the same
227
+ # way — reading only the leaf's own mark left `[^NP cats]` a triangle
228
+ # squashed into a gap that had been closed.
229
+ vertical_indent = if !triangle_asked_for?(parent, target) &&
225
230
  (@leafstyle == "nothing" || @leafstyle == "none") &&
226
231
  ETYPE_LEAF == target.type && parent.children.size == 1
227
232
  if @direction == "ltr"
@@ -395,6 +400,22 @@ module RSyntaxTree
395
400
  end
396
401
  end
397
402
 
403
+ # Whether a `^` has asked for a triangle over this leaf. It may be written
404
+ # at the head of the node's label or at the head of the leaf's own text —
405
+ # `[^NP cats]` and `[NP ^cats]` — and both forms are in the gallery. Only
406
+ # the first was honoured here, and the second was dropped without a word:
407
+ # the caret vanished from the text and a bar was drawn, so an example named
408
+ # for its triangles had none. The rest of the layout already reads the
409
+ # leaf's own flag — a leaf marked this way keeps the gap a triangle needs
410
+ # even when connectors are off — which is what left the two sides of one
411
+ # rule disagreeing.
412
+ #
413
+ # Asked of a leaf only. A `^` on an internal node is that node's own mark,
414
+ # and it is honoured when that node is in turn the parent here.
415
+ def triangle_asked_for?(parent, child)
416
+ parent.triangle || (ETYPE_LEAF == child.type && child.triangle)
417
+ end
418
+
398
419
  def draw_connector(id = 1)
399
420
  parent = @element_list.get_id(id)
400
421
  children = parent.children.map { |c| @element_list.get_id(c) }
@@ -410,21 +431,22 @@ module RSyntaxTree
410
431
 
411
432
  if children.size == 1
412
433
  child = children[0]
434
+ forced = triangle_asked_for?(parent, child)
413
435
  case @leafstyle
414
436
  when "auto"
415
- if parent.triangle || child.contains_phrase
437
+ if forced || child.contains_phrase
416
438
  triangle_to_parent(parent, child)
417
439
  else
418
440
  line_to_parent(parent, child)
419
441
  end
420
442
  when "bar"
421
- if parent.triangle
443
+ if forced
422
444
  triangle_to_parent(parent, child)
423
445
  else
424
446
  line_to_parent(parent, child)
425
447
  end
426
448
  when "nothing", "none"
427
- if parent.triangle
449
+ if forced
428
450
  triangle_to_parent(parent, child)
429
451
  elsif ETYPE_LEAF != child.type
430
452
  line_to_parent(parent, child)
@@ -82,21 +82,22 @@ module RSyntaxTree
82
82
 
83
83
  if children.size == 1
84
84
  child = children[0]
85
+ forced = triangle_asked_for?(parent, child)
85
86
  case @leafstyle
86
87
  when "auto"
87
- if parent.triangle || child.contains_phrase
88
+ if forced || child.contains_phrase
88
89
  triangle_to_parent(parent, child)
89
90
  else
90
91
  line_to_parent(parent, child)
91
92
  end
92
93
  when "bar"
93
- if parent.triangle
94
+ if forced
94
95
  triangle_to_parent(parent, child)
95
96
  else
96
97
  line_to_parent(parent, child)
97
98
  end
98
99
  when "nothing", "none"
99
- if parent.triangle
100
+ if forced
100
101
  triangle_to_parent(parent, child)
101
102
  elsif ETYPE_LEAF != child.type
102
103
  line_to_parent(parent, child)
@@ -1,4 +1,4 @@
1
- RSyntaxTree examples: 75 trees, every one verified to draw.
1
+ RSyntaxTree examples: 76 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;
@@ -279,21 +279,36 @@ Source: Radford 2004
279
279
  ## 011 — CCG derivation: forward and backward application
280
280
 
281
281
  Category: Combinatory Categorial Grammar
282
- Settings: color=none derivation=on direction=btt fontstyle=noto-serif leafstyle=nothing tidy=low vheight=0.7
282
+ Settings: color=none derivation=on direction=btt fontstyle=noto-serif hspacing=2.0 leafstyle=nothing tidy=low vheight=0.5
283
283
  Source: Steedman 2000
284
284
 
285
285
  ```
286
- [S\t< [NP\t> [NP/N the] [N dog]] [S\\NP\t> [(S\\NP)/NP bit] [NP John]]]
286
+ [S\t<
287
+ [NP\t>
288
+ [NP/N the]
289
+ [N dog]]
290
+ [S\\NP\t>
291
+ [(S\\NP)/NP bit]
292
+ [NP John]]]
287
293
  ```
288
294
 
289
295
  ## 012 — CCG derivation: a relative clause
290
296
 
291
297
  Category: Combinatory Categorial Grammar
292
- Settings: color=none derivation=on direction=btt fontstyle=noto-serif leafstyle=nothing tidy=low vheight=0.7
298
+ Settings: color=none derivation=on direction=btt fontstyle=noto-serif hspacing=2.0 leafstyle=nothing tidy=low vheight=0.5
293
299
  Source: Steedman 2000
294
300
 
295
301
  ```
296
- [NP\t> [NP/N the] [N\t< [N man] [N\\N\t> [(N\\N)/(S/NP) that] [S/NP\t>B [S/(S\\NP)\t>T [NP Mary]] [(S\\NP)/NP saw]]]]]
302
+ [NP\t>
303
+ [NP/N the]
304
+ [N\t<
305
+ [N man]
306
+ [N\\N\t>
307
+ [(N\\N)/(S/NP) that]
308
+ [S/NP\t>B
309
+ [S/(S\\NP)\t>T
310
+ [NP Mary]]
311
+ [(S\\NP)/NP saw]]]]]
297
312
  ```
298
313
 
299
314
  ## 013 — HPSG sample
@@ -2485,3 +2500,24 @@ Settings: fontstyle=noto-serif tidy=low vheight=1.0
2485
2500
  [V [<> [<> sat]]]
2486
2501
  [PP [P [<> on]] [NP [D the] [N mat]]]]]
2487
2502
  ```
2503
+
2504
+ ## 081 — CCG derivation: right node raising
2505
+
2506
+ Category: Combinatory Categorial Grammar
2507
+ Settings: color=none derivation=on direction=btt fontstyle=noto-serif hspacing=2.0 leafstyle=nothing tidy=low vheight=0.5
2508
+ Source: Steedman 2000
2509
+
2510
+ ```
2511
+ [S\t>
2512
+ [S/NP\t<Φ>
2513
+ [S/NP\t>B
2514
+ [S/(S\\NP)\t>T
2515
+ [NP Mary]]
2516
+ [(S\\NP)/NP likes]]
2517
+ [conj and]
2518
+ [S/NP\t>B
2519
+ [S/(S\\NP)\t>T
2520
+ [NP Bill]]
2521
+ [(S\\NP)/NP hates]]]
2522
+ [NP London]]
2523
+ ```
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSyntaxTree
4
- VERSION = "1.13.0"
4
+ VERSION = "1.13.1"
5
5
  end
data/lib/rsyntaxtree.rb CHANGED
@@ -151,6 +151,18 @@ module RSyntaxTree
151
151
  fontset = {}
152
152
  params.each do |keystr, value|
153
153
  key = keystr.to_sym
154
+ # An option given as an empty string is an option not given. An HTML
155
+ # form posts a field for every control it carries, and a control with
156
+ # nothing selected posts the empty string — so a form that has outlived
157
+ # one of its own controls sends `format=` and every other option along
158
+ # with it. Read as a value, that is a choice nobody can have made, and
159
+ # it failed the whole request: the web UI's three Download buttons
160
+ # returned 500 for every input, with the reason nowhere the user could
161
+ # see it. Read as silence, the default stands, which is what the sender
162
+ # meant.
163
+ next if (OPTION_VALUES.key?(key) || NUMERIC_RANGES.key?(key)) &&
164
+ (value.nil? || value.to_s.strip.empty?)
165
+
154
166
  if OPTION_VALUES.key?(key) && !OPTION_VALUES[key].include?(value.to_s)
155
167
  raise RSTError.new(+"Error: invalid value for option '#{key}': #{value.inspect}",
156
168
  code: :invalid_option,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsyntaxtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichiro Hasebe