@digitallinguistics/dlx-js v0.17.10
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 for various linguistic objects. Works in both browser and Node.
See the reference documentation for complete details on how to use the library.
Installation
If using yarn:
yarn add @digitallinguistics/dlx-js
If using npm:
npm i --save @digitallinguistics/dlx-js
You can also include the dlx-js
script in your page using the DLx CDN.
<script src=https://cdn.digitallinguistics.io/scripts/dlx.js></script>
Or download the script manually:
curl https://digitallinguistics.blob.core.windows.net/scripts/dlx.js -o dlx.js
Including the DLx Library in Your Code
In Node, you can require()
the package in your JS files:
const dlx = require('dlx-js');
In the browser, the dlx-js
library may be used either as a module (all module types are supported, including ES6), or a regular script. If using the library as a regular script, dlx
will be made available as a global variable.
Using ES6 modules:
import * as dlx from './dlx.js';
Using CommonJS modules:
const dlx = require('dlx-js');
As a regular script:
<script src=dlx.js></script>
<script>
// `dlx` is available as a global variable
const { Language } = dlx.models;
</script>
Basic Usage
const { Sentence } = dlx.models;
const { Text } = dlx.models;
const { tokenize } = dlx.utils;
const sentence = new Sentence();
const text = new Text();
const tokens = tokenize('Hello world!');
See the reference documentation for complete details on how to use the library.
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.)
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 file test/spec/index.html
in your browser.
Want to Contribute?
Check out DLx's general contributing guidelines.
Maintainers
This repo is maintained by:
- Daniel W. Hieber (dhieber@umail.ucsb.edu)
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago