https://github.com/words/wordnet
Node module wrapper for WordNet dictionary.
https://github.com/words/wordnet
Last synced: 2 months ago
JSON representation
Node module wrapper for WordNet dictionary.
- Host: GitHub
- URL: https://github.com/words/wordnet
- Owner: words
- Created: 2013-11-04T23:53:12.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2022-02-11T04:51:04.000Z (over 4 years ago)
- Last Synced: 2025-12-21T13:51:32.091Z (6 months ago)
- Language: JavaScript
- Size: 7.97 MB
- Stars: 53
- Watchers: 4
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WordNet.js
Simple Node.js module for accessing [Princeton University's WordNet](http://wordnet.princeton.edu/) dictionary.
# Installation
$ npm install wordnet
# Usage
const wordnet = require('wordnet');
// (Required) Load the WordNet database.
await wordnet.init();
// List all available words.
let list = await wordnet.list();
// All methods return promises.
wordnet.lookup('enlightened')
.then((definitions) => {
definitions.forEach((def) => {
console.log(`type: ${def.meta.synsetType}`)
console.log(`${def.glossary}\n`);
});
})
.catch((e) => {
console.error(e);
});
Check out the [examples folder](examples) for more.
# API
### `wordnet.init([database_dir])`
Loads the WordNet database. Takes an optional folder path (as a `String`).
### `wordnet.lookup(word, [skipPointers])`
Returns definitions (metadata and glossary) for the given word. The definitions include pointers to related words, which can be omitted by passing `skipPointers = true`.
### `wordnet.list()`
Lists all available words in the WordNet database. If called before `wordnet.init()` finishes, it will return an empty array.
# License
MIT License
# 3rd-party License
[Princeton University's WordNet License](http://wordnet.princeton.edu/wordnet/license/)