DLx JavaScript Library

A JavaScript library for working with linguistic data in DLx format. For browser and Node.

Digital Linguistics (DLx) is the science of the digital data management of linguistic data, of the kind typically produced during language documentation projects. This repository contains a JavaScript library for working with linguistic data in the Data Format for Digital Linguistics (Daffodil). It includes models for various linguistic objects, useful data and constants, and other utilities for working with language data.

npm version npm downloads GitHub issues GitHub test workflow status Zenodo DOI GitHub GitHub stars

View the API documentation for this library.

Maintained by Daniel W. Hieber (University of California, Santa Barbara). Please cite this library using the following model:

Hieber, Daniel W. 2020. @digitallinguistics/javascript. DOI:10.5281/zenodo.597714.

Contents

Getting Help & Contributing

Overview

The DLx JavaScript library has the following exports. See the API documentation for complete details on the contents of this library.

Export Description
core Base classes and other code reused across this library. Most users will not need to use this module.
models A collection of objects representing common linguistic objects, such as Language, Lexeme, etc. These have various utility functions attached to them, and ensure that their data is valid according to the DLx Data Format.
utilities Assorted utilities for working with data in DLx format
utilities/regexp Useful regular expressions (e.g. languageTag.js, ISO.js)
utilities/types Type-checking methods (e.g. isLanguageTag.js, isISO.js)

Usage

  1. Install using npm (npm i @digitallinguistics/javascript) or yarn (yarn add @digitallinguistics/javascript), or download the library from the releases page and include the files you need in your project.

  2. In Node, import the library as follows:

import dlx from '@digitallinguistics/javascript';
  1. In HTML, link src/index.js in a script tag:
<script src=dlx/src/index.js type=module></script>
  1. If your project does not support ES modules or recent JavaScript syntax, you may need to bundle and/or transpile this module for use in your code, using libraries like Babel and webpack.

  2. Use the library in your code:

import { models } from '@digitallinguistics/javascript';

const { Lexeme } = models;

const lexeme = new Lexeme({/* lexeme data */})
  1. You can also import standalone submodules and files, rather than the entire library:
import types       from '@digitallinguistics/javascript/types';
import punctuation from '@digitallinguistics/javascript/models/Language.js';
  1. See the API documentation for complete details on using the library.