@farscrl/rumantsch-language-tools
v1.1.2
Published
A collection of tools is designed to aid in working with the Rumantsch (Romansh) language
Readme
Rumantsch Language Tools
A collection of tools for working with the Rumantsch (Romansh) language, published as an npm package.
Requirements
Node.js 18 or later (the Proofreader uses the global fetch API), or a modern browser. The package ships both CJS and ESM builds plus TypeScript types.
Installation
pnpm add @farscrl/rumantsch-language-toolsFeatures
- Tokenizer — splits text into individual tokens, handling Romansh-specific abbreviations and punctuation (based on stdlib-js/nlp-tokenize)
- Proofreader — hunspell-based spellchecker supporting all Romansh idioms
Supported idioms
| Code | Idiom |
|------|-------|
| rm-puter | Puter |
| rm-rumgr | Rumantsch Grischun |
| rm-surmiran | Surmiran |
| rm-sursilv | Sursilvan |
| rm-sutsilv | Sutsilvan |
| rm-vallader | Vallader |
These codes are exported as the Idioms type.
Usage
Tokenizer
import { Tokenizer } from "@farscrl/rumantsch-language-tools";
Tokenizer.tokenize('In test dal tokenizer.');
// ['In', 'test', 'dal', 'tokenizer']tokenize(text, keepPunctuation?, keepWhitespace?) — both flags default to false:
Tokenizer.tokenize('In test, dal tokenizer.', true);
// ['In', 'test', ',', 'dal', 'tokenizer', '.']Proofreader
import { Proofreader } from '@farscrl/rumantsch-language-tools';
const proofreader = await Proofreader.CreateProofreader('rm-surmiran');
await proofreader.proofreadText('Text correct');
// [] — no errors
await proofreader.proofreadText('in');
// [{ word: 'in', offset: 0, length: 2 }]
await proofreader.getSuggestions('corect');
// ['correct', ...]CreateProofreader fetches the idiom's .aff/.dic files, compiles a WebAssembly-backed Hunspell instance, and resolves once it's ready. It throws if the dictionary fails to load. Once resolved, proofreader.isLoaded is true and proofreader.version holds the dictionary's version string.
Dictionary files are fetched from https://www.spellchecker.pledarigrond.ch by default. To use a self-hosted mirror, pass a baseUrl option:
const proofreader = await Proofreader.CreateProofreader('rm-surmiran', {
baseUrl: 'https://your-host.example.com'
});Call unload() when you are done to free the dictionary from memory. The instance cannot be used afterwards:
proofreader.unload();Development
pnpm install # install dependencies
pnpm test # run tests
pnpm run build # compile to lib/
pnpm run lint # lintPublishing a new version
There is no CI publish pipeline — releases are cut locally.
On an up-to-date
mainwith a clean working tree, make sure you're logged in to npm (npm whoami).Bump the version, which lints (
preversion), formats and stagessrc/(version), then commits, tags, and pushes both the commit and the tag (postversion):pnpm version patch # or: minor / majorPublish to npm.
prepublishOnlyruns the full test suite and lint before publishing:pnpm publishIf this is the first publish under a new scope, add
--access public.
