A JavaScript library for converting linguistic data to a simple interlinear text.
Works in both Node and the browser.
tl;dr: This library converts data from DaFoDiL format to Scription format.
The Digital Linguistics (DLx) project provides a recommended format for storing linguistic data called DaFoDiL (The Data Format for Digital Linguistics). This library provides a converter which transforms DaFoDiL-formatted data into a simple text format frequently used in linguistics called an interlinear gloss. In particular, the DLx project offers a specification for how to format interlinear glosses in a way that is computer-readable, called Scription.
Here is a small example of an utterance in DaFoDiL format:
{
"metadata": "Swahili",
"transcription": {
"default": "ninakupenda"
},
"translation": "I love you",
"words": [
{
"transcription": {
"default": ""
},
"analysis": {
"default": "ni-na-ku-pend-a"
},
"gloss": "1sg-PRES-2sg-love-IND",
"morphemes": [
{
"transcription": {
"default": "ni"
},
"gloss": "1sg"
},
{
"transcription": {
"default": "na"
},
"gloss": "PRES"
},
{
"transcription": {
"default": "ku"
},
"gloss": "2sg"
},
{
"transcription": {
"default": "pend"
},
"gloss": "love"
},
{
"transcription": {
"default": "a"
},
"gloss": "IND"
}
]
}
]
}
And here is that same data in Scription format:
# Swahili
ninakupenda
ni-na-ku-pend-a
1sg-PRES-2sg-love-IND
I love you
This library is distributed as an npm
package and can be installed using npm
or other Node package mangers:
npm install @digitallinguistics/dlx2scription
import dlx2scription from '@digitallinguistics/dlx2scription'
To use this library in a browser, you can either import the script directly from the node_modules/
folder, or use a JavaScript bundler (Webpack, Rollup, Browserify, ESBuild, etc.) to bundle the library into a single file while you can import into your HTML:
<script type=module>
// Import a bundled copy of library.
import dlx2scription from './dlx2scription.js'
// OR
// Import directly from the `node_modules/` folder.
import dlx2scription from './node_modules/@digitallinguistics/dlx2scription/index.js'
</script>
The library exports a single method which accepts an Array of utterances in DaFoDiL format as the first argument, and an options hash as the second.
const utterances = [/* An array of utterances in DaFoDiL format. */]
const scription = dlx2scription(utterances, { /* options */ })
console.log(scription)
// # Swahili
// ninakupenda
// ni-na-ku-pend-a
// 1sg-PRES-2sg-love-IND
// I love you
The following options are available:
Option | Type | Default | Description |
---|---|---|---|
(forthcoming) |
To report a problem or request a feature, please open an issue here.