Skip to content

Commit a688f82

Browse files
dani-polaniclaude
andcommitted
fix: correct skill examples and API docs for article/gloss alignment
- world → le + monde: both words linked (article is part of noun phrase) - interlinear gloss: source→gloss adjacent (gapPx 12, showConnectors false), translation below; gloss tokens colored via connections to source - updated /api page example and skill SKILL.md + references/api.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a928204 commit a688f82

4 files changed

Lines changed: 60 additions & 24 deletions

File tree

bitext/src/routes/api/+page.svelte

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,13 @@
164164
"lines": ["Hello world", "Bonjour le monde"],
165165
"alignments": [
166166
[0, 0, 1, 0],
167+
[0, 1, 1, 1],
167168
[0, 1, 1, 2]
168169
]
169170
}'`}</pre>
170171
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
171-
Links "Hello" → "Bonjour" (word 0 → word 0) and "world" → "monde" (word 1 → word 2; "le" is
172-
word 1, "monde" is word 2).
172+
Links "Hello" → "Bonjour" (word 0 → word 0). "world" → "le" + "monde" (words 1 and 2) — the
173+
French article is part of the noun phrase, so both words share the same color.
173174
</p>
174175

175176
<h3 class={subheadingClass}>Example — many-to-one (one word maps to several)</h3>
@@ -426,23 +427,24 @@
426427
-H "Content-Type: application/json" \\
427428
-d '{
428429
"lines": [
429-
"Я ходил",
430-
"I have been going",
431-
"1SG.NOM PST.IPFV"
430+
{ "text": "Я ходил", "sizePx": 40 },
431+
{ "text": "1SG.NOM PST.IPFV", "sizePx": 22 },
432+
{ "text": "I have been going", "sizePx": 36 }
432433
],
433434
"alignments": [
434-
[0, 0, 1, 0],
435-
[0, 1, 1, 1],
436-
[0, 1, 1, 2],
437-
[0, 1, 1, 3]
435+
[0, 0, 1, 0], [0, 0, 1, 1],
436+
[0, 1, 1, 2], [0, 1, 1, 3]
438437
],
439438
"pairs": [
440-
{ "upper": 1, "lower": 2, "gapPx": 60, "showConnectors": false }
439+
{ "upper": 0, "lower": 1, "gapPx": 12, "showConnectors": false },
440+
{ "upper": 1, "lower": 2, "gapPx": 80, "showConnectors": false }
441441
]
442442
}'`}</pre>
443443
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
444-
Connectors are drawn between lines 0–1. Line 2 is a gloss row with a smaller gap and no
445-
connectors.
444+
Gloss is adjacent to source (lines 0–1) with a 12 px gap and hidden arcs — tokens are colored
445+
but no lines are drawn. Dots in the gloss text are split characters: <span class={codeClass}>"1SG.NOM"</span>
446+
becomes two tokens (word 0 = <em>1SG</em>, word 1 = <em>NOM</em>). The free translation sits
447+
below with a larger gap.
446448
</p>
447449

448450
<!-- ── Word indices ────────────────────────────────────────── -->

word-aligner-skill.zip

518 Bytes
Binary file not shown.

word-aligner-skill/SKILL.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ If uncertain about tokenization, call `GET https://aligner.tinygods.dev/api/alig
4545
}
4646
```
4747

48+
**One-to-many** (article + noun both correspond to one source word): include both target words.
49+
50+
```json
51+
{
52+
"lines": ["Hello world", "Bonjour le monde"],
53+
"alignments": [[0,0,1,0], [0,1,1,1], [0,1,1,2]]
54+
}
55+
```
56+
"world" maps to both "le" (word 1) and "monde" (word 2) — they share a color.
57+
4858
**RTL language** (Hebrew, Arabic, etc.): use a `LineInput` object with `"rtl": true` and a matching font.
4959

5060
```json
@@ -57,16 +67,30 @@ If uncertain about tokenization, call `GET https://aligner.tinygods.dev/api/alig
5767
}
5868
```
5969

60-
**3 lines with a gloss row**: add `pairs` to hide connectors on the gloss pair.
70+
**Interlinear gloss**: place the gloss line directly under the source (adjacent), connect source→gloss tokens, hide the arcs with `showConnectors: false`, use a small gap (12px). Put the free translation below the gloss with a larger gap and no connectors.
71+
72+
`"1SG.NOM PST.IPFV"` — dots are default split chars, so this yields 4 tokens: `1SG`[0] `NOM`[1] `PST`[2] `IPFV`[3].
6173

6274
```json
6375
{
64-
"lines": ["Я ходил", "I have been going", "1SG.NOM PST.IPFV"],
65-
"alignments": [[0,0,1,0], [0,1,1,1], [0,1,1,2], [0,1,1,3]],
66-
"pairs": [{"upper": 1, "lower": 2, "gapPx": 60, "showConnectors": false}]
76+
"lines": [
77+
{"text": "Я ходил", "sizePx": 40},
78+
{"text": "1SG.NOM PST.IPFV", "sizePx": 22},
79+
{"text": "I have been going", "sizePx": 36}
80+
],
81+
"alignments": [
82+
[0,0,1,0], [0,0,1,1],
83+
[0,1,1,2], [0,1,1,3]
84+
],
85+
"pairs": [
86+
{"upper": 0, "lower": 1, "gapPx": 12, "showConnectors": false},
87+
{"upper": 1, "lower": 2, "gapPx": 80, "showConnectors": false}
88+
]
6789
}
6890
```
6991

92+
Gloss tokens inherit colors from their source-word group. Arcs are hidden on both pairs; only the color coding is visible.
93+
7094
## Full parameter reference
7195

7296
See [references/api.md](references/api.md) for the complete parameter tables: `LineInput`, `SettingsInput` (palette, lineStyle, lineThickness, lineOpacity, background, theme, showNumbers, colorTokensByLink), and `PairInput` (gapPx, showConnectors).

word-aligner-skill/references/api.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,14 @@ Returns the same `{ "url": "..." }` response. Useful for opening the editor pre-
9292

9393
## Examples
9494

95-
### Simple two-language alignment
95+
### Simple two-language alignment (article + noun both linked to one source word)
9696
```json
9797
{
9898
"lines": ["Hello world", "Bonjour le monde"],
99-
"alignments": [[0,0,1,0], [0,1,1,2]]
99+
"alignments": [[0,0,1,0], [0,1,1,1], [0,1,1,2]]
100100
}
101101
```
102+
"world" maps to both "le" (word 1) and "monde" (word 2) — they share a color.
102103

103104
### Custom visual style (vivid, dark)
104105
```json
@@ -134,16 +135,25 @@ Returns the same `{ "url": "..." }` response. Useful for opening the editor pre-
134135
}
135136
```
136137

137-
### Three lines — source + translation + gloss
138+
### Three lines — source + gloss + free translation
139+
Gloss is adjacent to source (lines 0–1), arcs hidden but colors shown. Translation is below.
140+
Dots in gloss are split chars: `"1SG.NOM PST.IPFV"` → tokens `1SG`[0] `NOM`[1] `PST`[2] `IPFV`[3].
141+
138142
```json
139143
{
140144
"lines": [
141-
"Я ходил",
142-
"I have been going",
143-
"1SG.NOM PST.IPFV"
145+
{"text": "Я ходил", "sizePx": 40},
146+
{"text": "1SG.NOM PST.IPFV", "sizePx": 22},
147+
{"text": "I have been going", "sizePx": 36}
148+
],
149+
"alignments": [
150+
[0,0,1,0], [0,0,1,1],
151+
[0,1,1,2], [0,1,1,3]
144152
],
145-
"alignments": [[0,0,1,0], [0,1,1,1], [0,1,1,2], [0,1,1,3]],
146-
"pairs": [{"upper": 1, "lower": 2, "gapPx": 60, "showConnectors": false}]
153+
"pairs": [
154+
{"upper": 0, "lower": 1, "gapPx": 12, "showConnectors": false},
155+
{"upper": 1, "lower": 2, "gapPx": 80, "showConnectors": false}
156+
]
147157
}
148158
```
149159

0 commit comments

Comments
 (0)