self-dict
v1.0.0
Published
Offline dictionary: definitions, parts of speech, and synonyms powered by WordNet.
Downloads
96
Maintainers
Readme
self-dict
A fully self-hosted, offline Node.js dictionary. Input a word, get back its definition(s), part(s) of speech, and synonyms — no API keys, no internet required.
Powered by WordNet via wordpos. The entire WordNet database (~30MB) is bundled as a local dependency after install.
Requirements
- Node.js 18+
Installation
npm installThe wordpos package ships the full WordNet database locally — nothing else to configure.
Usage
As a module
const { define } = require('./index');
const result = await define('ephemeral');
console.log(JSON.stringify(result, null, 2));From the command line
node cli.js serendipityOr, if installed globally (npm install -g .):
self-dict serendipityRun the example script
npm run exampleOutput shape
{
"word": "ephemeral",
"types": ["adjective"],
"definitions": [
{
"type": "adjective",
"definition": "lasting a very short time",
"example": "the ephemeral joys of childhood"
}
],
"synonyms": ["short-lived", "transient", "transitory", "fugacious", "passing"]
}| Field | Type | Description |
|---------------|------------|-------------------------------------------------------|
| word | string | The queried word (normalised to lowercase) |
| types | string[] | Parts of speech: noun, verb, adjective, adverb |
| definitions | object[] | Each has type, definition, and optional example |
| synonyms | string[] | Deduplicated synonyms from WordNet synsets |
Error handling
try {
const result = await define('xyzzy');
} catch (err) {
// err.message → 'Word not found: "xyzzy"'
}Throws a TypeError for bad input and an Error if the word isn't found in WordNet.
License
MIT
