https://github.com/digitallinguistics/word-aligner
A small JavaScript utility for vertically aligning interlinear glosses
https://github.com/digitallinguistics/word-aligner
corpus-linguistics digital-humanities digital-linguistics dlx glossing interlinear interlinear-gloss linguistics
Last synced: 7 months ago
JSON representation
A small JavaScript utility for vertically aligning interlinear glosses
- Host: GitHub
- URL: https://github.com/digitallinguistics/word-aligner
- Owner: digitallinguistics
- License: mit
- Created: 2020-07-06T14:18:27.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-12T00:02:48.000Z (over 4 years ago)
- Last Synced: 2025-03-17T22:07:39.536Z (7 months ago)
- Topics: corpus-linguistics, digital-humanities, digital-linguistics, dlx, glossing, interlinear, interlinear-gloss, linguistics
- Language: JavaScript
- Homepage: https://developer.digitallinguistics.io/word-aligner/
- Size: 241 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# word-aligner
_word-aligner_ is a small JavaScript utility (Node / browser) for vertically aligning words in an interlinear gloss (or any multi-line format).
[][releases]
[][npm]
[][issues]
[][actions]
[][Zenodo]
[][license]
[][GitHub][Click here to open an issue on GitHub.][new-issue]
## Basic Usage
Install the library using npm or yarn:
```cmd
npm i @digitallinguistics/word-aligner
yarn add @digitallinguistics/word-aligner
```Import the module:
```js
import alignWords from '@digitallinguistics/word-aligner';
```Run the utility on an array of the lines you'd like to vertically align:
```js
const lines = [
`waxdungu qasi`,
`waxt-qungu qasi`,
`day-one man`,
];const aligned = alignWords(lines);
```The value of the `aligned` variable will be:
```txt
[
"waxdungu qasi",
"waxt-qungu qasi",
"day-one man"
]
```**Note:** _word-aligner_ does _not_ do automatic line detection. It will not know what type of line you are handing it (morphemes, glosses, translation, etc.). Only provide the lines you actually want aligned. Usually this means you will not provide a free translation line.
## Options
Option | Default | Description
-----------------|----------|------------
`alignmentError` | `false` | Specifies whether the library should throw an error if all lines do not have the same number of words.
`groupWith` | `[]` | Specifies a pair of characters to use to group words together in a line. Any words enclosed by these characters will be treated as a single word by the library.
`separator` | `spaces` | Specifies whether words should be aligned using spaces or tabs. Allowed values: `spaces`, `tabs`.[actions]: https://github.com/digitallinguistics/word-aligner/actions?query=workflow%3Atest
[GitHub]: https://github.com/digitallinguistics/word-aligner
[issues]: https://github.com/digitallinguistics/word-aligner/issues
[license]: https://github.com/digitallinguistics/word-aligner/blob/main/LICENSE
[new-issue]: https://github.com/digitallinguistics/word-aligner/issues/new
[npm]: https://www.npmjs.com/package/@digitallinguistics/word-aligner
[releases]: https://github.com/digitallinguistics/word-aligner/releases
[Zenodo]: https://zenodo.org/badge/latestdoi/277561856