Hunspell dictionaries in UTF-8
Collection of normalized and installable hunspell dictionaries.
This monorepo is a bunch of scripts that crawls dictionaries from several sources, normalizes them, and packs them so that they can each be installed and used in one single way. Dictionaries are not maintained here but they are usable from here.
You can particularly use the packages here as a programmer when integrating with
other tools (such as nodehun
or nspell
)
or when making such tools.
These packages are ESM only. In Node.js (version 16+), install with npm:
npm install dictionary-en
👉 Note: replace
en
with the language code you want.⚠️ Important: this project itself is MIT, but each
index.dic
andindex.aff
file still has its original license!
import en from 'dictionary-en'
console.log(en)
// To do: use `en` somehow
Yields:
{aff: <Buffer>, dic: <Buffer>}
👉 Note: preferred BCP-47 codes are used (according to Unicode CLDR). To illustrate, as American English and Brazilian Portuguese are the most common types of English and Portuguese respectively, they get the codes
en
andpt
.
In total 92 dictionaries are provided.
nspell
This example uses dictionary-en
in combination with
nspell
.
npm install dictionary-en nspell
import en from 'dictionary-en'
import nspell from 'nspell'
const spell = nspell(en)
console.log(spell.correct('color'))
console.log(spell.correct('colour'))
Yields:
true
false
This example loads the index.dic
and index.aff
files located in
dictionary-hyw
(Western Armenian) from a Node.js JavaScript module (ESM).
It uses a ponyfill (import-meta-resolve
) for
an experimental Node API.
npm install dictionary-hyw import-meta-resolve
import fs from 'node:fs/promises'
import {resolve} from 'import-meta-resolve'
const base = await resolve('dictionary-hyw', import.meta.url)
const aff = await fs.readFile(new URL('index.aff', base))
const dic = await fs.readFile(new URL('index.dic', base))
console.log(aff, dic)
Follow these steps to use a dictionary on macOS:
dictionaries/$code
(replace $code
with the language code you
want)index.aff
and index.dic
files (as in open them,
right-click “Raw”,
and “download linked files”)$code.aff
and $code.dic
$code.aff
and $code.dic
into the folder ~/Library/Spelling/
(Library)
suffix and
is situated at the bottom)The packages are typed with TypeScript.
These packages are safe.
Yes please! See How to Contribute to Open Source.
To build this project, on macOS, you at least need to install:
brew install wget
(crawling)brew install hunspell
(many dictionaries)brew install gnu-sed
(crawling, many dictionaries)brew install coreutils
(many dictionaries)brew install ispell
(German)👉 Note: sed and the GNU replacements should be setup in PATH to overwrite macOS defaults.
Dictionaries are not maintained here. Report problems upstream.
Dictionaries are not maintained here. Most languages have a small community or institute that maintains a dictionary, and they often do so on GitHub or similar. Please ask in the issues to request that such a dictionary is included here.
👉 Note: acceptable dictionaries must:
- have a significant affix file (not just a
.dic
file)- have an open source license
- have recent contributions
MIT © Titus Wormer
See license
files in each dictionary for the licensing of index.dic
and
index.aff
files.