DLx JavaScript SDK
Digital Linguistics (DLx) is the science of the digital management of linguistic data, of the kind typically produced by linguists during language documentation projects. This repository contains a JavaScript library for working with linguistic data in the Digital Linguistics data format. It includes Models, Views, and HTML Templates for various linguistic objects. Works in both browser and Node.
This library complies with v0.12.0 of the Digital Linguistics data format.
Documentation
View the complete documentation for this library here.
Installation & Basic Usage
Node
Install via npm:
npm i --save dlx-js
Then require()
the package in your JS files:
const dlx = require('dlx-js');
const Phrase = dlx.models.Phrase;
const Text = dlx.models.Text;
const tokenize = dlx.utils.tokenize;
const phrase = new Phrase();
const text = new Text();
const tokens = tokenize('Hello world!');
Browser
Include the dlx.js
file in your HTML page using the DLx CDN:
<script type=text/javascript src=//cdn.digitallinguistics.io/scripts/dlx.js></script>
Or download the file and include it locally:
<script type=text/javascript src=path/to/file/dlx.js></script>
Then dlx
will be available as a global object:
const phrase = new dlx.models.Phrase();
const text = new dlx.models.Text();
const phraseView = new PhraseView(phrase);
const textView = new TextView(text);
Documentation
View the complete documentation for this library here.
Notes
- The
MultiLangString
object can be accessed either viadlx.models.MultiLangString
ordlx.models.String
(to avoid conflict with the globalString
object). - The
Location
object can be accessed either viadlx.models.Location
ordlx.models.Place
(to avoid conflict with the globalLocation
object in browsers). - The Utilities module can be accessed as either
dlx.utilities
ordlx.utils
. - All models validate their own data when they are created.
- The
dlx-js
library always supports the latest major version of the DLx schemas. It is not guaranteed to support older versions. However, minor versions within the same major release are supported. (For example, if the current version of the DLx format is5.2.0
, thedlx-js
library will also support versions5.1.0
and5.0.0
, but not version4.x
or lower.)
Developers
Tests
Tests were created using Jasmine. To run the Node tests, make sure you have Jasmine installed, install dlx-js
, then run npm test
in your project directory. To run the tests in the browser, download the dlx-js
repository, and open the files test/spec/index.html
and test/views/index.html
in your browser.
Build Scripts
npm run bundle
: Bundles the source files intodlx.js
.npm run docs
: Generates the JSDoc files and outputs them to thedocs
folder.