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.
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
-
Have a question? Ask it here.
-
Want to request a feature or improvement? Make a feature request here.
-
Found a bug or other problem? File a bug report here.
-
Want to contribute code to the project? Check out the contributing guidelines.
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
-
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. -
In Node, import the library as follows:
import dlx from '@digitallinguistics/javascript';
- In HTML, link
src/index.js
in a script tag:
<script src=dlx/src/index.js type=module></script>
-
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.
-
Use the library in your code:
import { models } from '@digitallinguistics/javascript';
const { Lexeme } = models;
const lexeme = new Lexeme({/* lexeme data */})
- 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';
- See the API documentation for complete details on using the library.