WordNet Database Files for Node.js

3.1.14 · active · verified Tue Apr 21

wordnet-db is a specialized Node.js package designed to provide the complete database files for WordNet 3.1 directly within an npm installation. Currently at version 3.1.14, it offers a robust solution for developers requiring offline access to the Princeton WordNet lexical database, which is particularly useful for natural language processing libraries like `wordpos` and `natural`. The package differentiates itself by pre-bundling the entire 34 MB uncompressed WordNet dictionary, eliminating the need for on-demand downloads or complex setup scripts during application runtime. Its release cadence is primarily reactive, addressing compatibility with newer Node.js versions, fixing installation-related issues, or updating to newer WordNet database versions (though it has been stable on WordNet 3.1 for a while). This ensures that applications can deploy with a guaranteed, self-contained WordNet data source, even in environments with restricted internet access.

Common errors

Warnings

Install

Imports

Quickstart

This script demonstrates how to import `wordnet-db`, access its properties (like path and versions), and verify the presence and content of a sample WordNet data file.

const wordnetDb = require('wordnet-db');
const fs = require('fs');
const path = require('path');

console.log('--- WordNet DB Information ---');
console.log(`Package version: ${wordnetDb.libVersion}`);
console.log(`WordNet data version: ${wordnetDb.version}`);
console.log(`Database files path: ${wordnetDb.path}`);
console.log(`Number of files: ${wordnetDb.files.length}`);

// Verify a common WordNet data file exists
const exampleFile = 'data.noun';
const fullPath = path.join(wordnetDb.path, exampleFile);

console.log(`\nChecking for existence of "${exampleFile}" at "${fullPath}"...`);

try {
  fs.accessSync(fullPath, fs.constants.F_OK);
  console.log(`SUCCESS: "${exampleFile}" found. WordNet database seems correctly installed.`);

  // Optionally, read a few lines to confirm content
  const content = fs.readFileSync(fullPath, 'utf8');
  console.log(`First 3 lines of ${exampleFile}:\n${content.split('\n').slice(0, 3).join('\n')}`);

} catch (err) {
  console.error(`ERROR: "${exampleFile}" not found or inaccessible. Installation may be incomplete or corrupted.`);
  console.error(err.message);
}

view raw JSON →