|
| 1 | +--- |
| 2 | +name: word-aligner |
| 3 | +description: Use Word Aligner to create shareable visual diagrams showing word-by-word alignment between two or more texts. Invoke this skill when the user wants to translate a phrase and show which words correspond to which, align a translation with its source in any language (including RTL scripts like Hebrew or Arabic), create an interlinear gloss or morpheme breakdown, or generate a shareable alignment diagram. The skill calls POST https://aligner.tinygods.dev/api/align and returns a URL. |
| 4 | +--- |
| 5 | + |
| 6 | +# Word Aligner |
| 7 | + |
| 8 | +Word Aligner generates shareable interactive diagrams showing which words in one text correspond to which words in another. Words are connected by colored arcs; tokens sharing a connection group (many-to-one or one-to-many) get the same color automatically. |
| 9 | + |
| 10 | +**API endpoint:** `POST https://aligner.tinygods.dev/api/align` |
| 11 | +**Returns:** `{ "url": "https://aligner.tinygods.dev/?data=..." }` — give this URL to the user. |
| 12 | + |
| 13 | +## Minimal request |
| 14 | + |
| 15 | +```json |
| 16 | +{ |
| 17 | + "lines": ["Hello world", "Bonjour le monde"], |
| 18 | + "alignments": [[0, 0, 1, 0], [0, 1, 1, 2]] |
| 19 | +} |
| 20 | +``` |
| 21 | + |
| 22 | +`alignments` entries are `[lineA, wordA, lineB, wordB]` — 0-based indices, lines must be adjacent. |
| 23 | + |
| 24 | +## Workflow |
| 25 | + |
| 26 | +1. Translate the phrase yourself (or use the user's existing translation). |
| 27 | +2. Identify which source words correspond to which target words. |
| 28 | +3. Call the API. |
| 29 | +4. Return the `url` to the user with a brief explanation. |
| 30 | + |
| 31 | +## Word index counting |
| 32 | + |
| 33 | +Count left to right from 0, splitting on whitespace. Characters `.` `-` `|` also split. For RTL lines, word 0 is the logically first word (rightmost on screen). |
| 34 | + |
| 35 | +If uncertain about tokenization, call `GET https://aligner.tinygods.dev/api/align?lines=your+text` first and open the URL to count word boxes in the editor. |
| 36 | + |
| 37 | +## Common patterns |
| 38 | + |
| 39 | +**Many-to-one** (one source word → several target words): list all target words as separate alignment tuples. They share a color automatically. |
| 40 | + |
| 41 | +```json |
| 42 | +{ |
| 43 | + "lines": ["Я ходил", "I have been going"], |
| 44 | + "alignments": [[0,0,1,0], [0,1,1,1], [0,1,1,2], [0,1,1,3]] |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +**RTL language** (Hebrew, Arabic, etc.): use a `LineInput` object with `"rtl": true` and a matching font. |
| 49 | + |
| 50 | +```json |
| 51 | +{ |
| 52 | + "lines": [ |
| 53 | + {"text": "שלום עולם", "rtl": true, "font": "Noto Sans Hebrew", "sizePx": 48}, |
| 54 | + {"text": "Hello world", "sizePx": 40} |
| 55 | + ], |
| 56 | + "alignments": [[0,0,1,0], [0,1,1,1]] |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +**3 lines with a gloss row**: add `pairs` to hide connectors on the gloss pair. |
| 61 | + |
| 62 | +```json |
| 63 | +{ |
| 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}] |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +## Full parameter reference |
| 71 | + |
| 72 | +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). |
0 commit comments