Registry / ai-ml / parse-latin

parse-latin

JSON →
library7.0.0jsnpmunverified

`parse-latin` is a JavaScript library designed for parsing natural language written in Latin-script languages, producing a Natural Language Concrete Syntax Tree (NLCST). It is currently at version 7.0.0, with a release cadence that includes regular patch and minor updates, and significant breaking changes between major versions, often related to ecosystem standards (like ESM-only) or core API adjustments. Key differentiators include its ability to precisely tokenize and structure text from diverse Latin-script languages such as Old English, Icelandic, French, and German, by correctly handling complex punctuation, word boundaries, and sentence structures. Unlike higher-level abstractions like `retext-latin`, `parse-latin` provides a lower-level API for manual manipulation of syntax trees. It explicitly handles nuances like hyphenated words, contractions (e.g., 'she’s'), and periods that don't signify sentence endings (e.g., in abbreviations), making it robust for detailed linguistic analysis and processing.

npm install parse-latin
INSTALL
IMPORT
SIG · PARSE-LATIN
P
parse-latin
ai-mljavascriptv7.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ParseLatin
import { ParseLatin } from 'parse-latin'
const ParseLatin = require('parse-latin')
The `parse-latin` package is ESM-only since v5.0.0. For Node.js, version 16 or higher is required since v7.0.0.
RootNode
import type { RootNode } from 'nlcst'
import { RootNode } from 'parse-latin'
The `RootNode` type, which `parse-latin` produces, is defined in the `nlcst` package. Install `nlcst` separately to access these types for robust type-checking.
Node
import type { Node } from 'unist'
import { Node } from 'parse-latin'
NLCST trees extend Unist trees. The base `Node` type for generic tree manipulation is provided by the `unist` package. Install `unist` to get these types.

Demonstrates how to initialize `ParseLatin` and parse a sample Latin-script string into an NLCST syntax tree, then logs the inspected tree structure.

import {ParseLatin} from 'parse-latin' import {inspect} from 'unist-util-inspect' // Make sure to install 'unist-util-inspect' separately: npm install unist-util-inspect // Initialize the parser const parser = new ParseLatin() // Parse a comprehensive Latin-script text const tree = parser.parse(` A truly simple sentence for demonstration. This is another sentence, featuring some hyphenated words like "well-being" and common abbreviations such as "e.g.", "i.e.", and "etc." Periods, question marks? And exclamation points! all mark sentence boundaries. Special characters like © and ® are treated as symbols. What about numbers? 1, 2, 3. Paragraphs are also recognized. New paragraph starts here. It might contain quotes like "Hello world!" or parenthetical expressions (like this one). The parser aims to correctly segment words, punctuation, and sentences according to Latin-script rules. For example, "U.S.A." is a single word token. `) console.log(inspect(tree))
Debug
Known issues
breakingNode.js 16 or higher is now required to use `parse-latin`.
fix
Upgrade your Node.js environment to version 16 or newer.
affects: >=7.0.0
breakingThe package is now ESM-only (ECMAScript Modules). CommonJS `require()` is no longer supported.
fix
Refactor your imports to use ES Modules syntax (`import`/`export`). Ensure your project is configured for ESM by setting `"type": "module"` in `package.json` or using `.mjs` file extensions.
affects: >=5.0.0
breakingThe `position` field on NLCST nodes is no longer available by default. This change was implemented to reduce bundle size.
fix
If you relied on positional information, use `unist-util-position` to add it back to the tree. If you previously set `position: false`, this change aligns with that behavior.
affects: >=6.0.0
breakingThe `use` and `useFirst` options for plugin management have been removed from the parser API.
fix
Manually manage your plugin lists or middleware for tree manipulation outside of the `ParseLatin` constructor.
affects: >=6.0.0
breakingThe package now strictly uses the `exports` field in `package.json`. Direct imports of private or internal APIs are no longer supported.
fix
Only import public APIs from the package as documented. Avoid deep imports into internal paths or undocumented modules.
affects: >=7.0.0
breakingThe `doc` field for nodes now explicitly uses `undefined` instead of `null` or an empty string for missing documentation.
fix
Update any code that checks the `doc` field to explicitly expect `undefined` instead of other falsy values.
affects: >=7.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` to import `parse-latin` in an ESM context or a Node.js version below 16.
fix
Change `const { ParseLatin } = require('parse-latin')` to `import { ParseLatin } from 'parse-latin'`. Ensure Node.js 16+ is used and `package.json` specifies `"type": "module"`.
TypeError: ParseLatin(...).parse is not a function
Attempting to call `ParseLatin` as a function directly instead of instantiating it as a class.
fix
Instantiate the parser using `const parser = new ParseLatin();` before calling `parser.parse(value)`.
SyntaxError: Cannot use import statement outside a module
Trying to use ESM `import` syntax in a CommonJS module or an environment not configured for ESM, especially relevant since v5.
fix
Ensure your `package.json` contains `"type": "module"` or that your file has a `.mjs` extension. For older Node.js environments, consider transpiling.
TypeError: inspect is not a function
The `unist-util-inspect` utility used in the quickstart example to visualize the tree is not installed.
fix
Install `unist-util-inspect` separately: `npm install unist-util-inspect`.
Upgrade
Version history
7.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources