View on GitHub

scription2dlx

A JavaScript library that converts scription text files to the Data Format for Digital Linguistics

scription2dlx

npm (scoped) npm GitHub issues Travis (.org) branch GitHub GitHub stars

A JavaScript library that converts linguistic texts in scription format to the Data Format for Digital Linguistics (DaFoDiL). It runs in recent versions of browsers and Node.js. This library is useful for language researchers who want to work with their data in text formats that are simple to type and read (scription), but want to convert their data for use in other Digital Linguistics tools.

Installation

Node

Install the library in your project from the command line: npm i @digitallinguistics/scription2dlx

Browser

Option 1: Include the scription2dlx library as a script in your HTML from the DLx CDN:

<script src=https://cdn.digitallinguistics.io/scripts/scription2dlx-1.0.0.js></script>

Option 2: Download the scription2dlx.js file from the releases page and include it in a script tag in your HTML:

<script src=scription2dlx.js></script>

Option 3: Install scription2dlx in your project using npm (see above), and then include the script in your HTML with a script tag. You may choose to use either the bundled distribution or the distribution that supports ES modules:

<script src=node_modules/@digitallinguistics/scription2dlx/scription2dlx.js></script>

Usage

The library exports a single function, scription2dlx, which accepts a String and returns a DaFoDiL Text Object.

data.txt

---
title: How the world began
---
waxdungu qasi
one day a man

script.js

const data = await fetch(`data.txt`);
const text = scription2dlx(data);
console.log(text.utterances.transcription); // "waxdungu qasi"

You may also pass an options hash as the second option. The available options are shown below.

const text = scription2dlx(data, { /* options */ });

Notes

Options

Option Default Description
codes {} This option allows you to use custom backslash codes in your interlinear glosses. It should be a hash containing the scription code as a key (without a leading backslash), and the custom code as the value; ex: "txn": "t" will allow you to write \t instead of \txn for transcription lines.
parser undefined A YAML parser to use to parse the header of a scription document. If none is present, the header will be provided as a string in the header property of the returned object.

Using as a Dependency

If you would like to include scription2dlx as a dependency in your own library, you can use the files in the /src directory to transpile / bundle scription2dlx with your own code. The source code for scription2dlx is written using ES modules and the latest JavaScript syntax.