Registry / serialization / wordpos

wordpos

JSON →
library2.1.0jsnpmunverified

wordpos is a set of fast part-of-speech (POS) utilities for both Node.js and browser environments, leveraging the WordNet database for its linguistic data. The current stable version is 2.1.0, which marked a significant refactoring to enable full browser compatibility, overcoming previous limitations regarding the size and un-browserify-ability of the WordNet database. While a specific release cadence isn't published, the project has undergone major version updates (1.x, 2.x) that introduced substantial performance improvements (up to 5x faster than prior versions), promise-based APIs, and a decoupling from the `natural` library's WordNet module. Its key differentiators include its speed, cross-environment support, a flexible API with options for stopword filtering and profiling, and a command-line interface.

npm install wordpos
INSTALL
IMPORT
SIG · WORDPOS
W
wordpos
serializationjavascriptv2.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WordPOS
import WordPOS from 'wordpos';
import { WordPOS } from 'wordpos';
WordPOS is a default export representing the main class for POS operations. Named imports will fail.
WordPOS
const WordPOS = require('wordpos');
import WordPOS from 'wordpos';
CommonJS `require` is the primary import mechanism shown in documentation for Node.js environments. Attempting to use ESM import syntax in a CJS module will lead to errors.
wordpos.getAdjectives
wordpos.getAdjectives('text', callback);
wordpos.getAdjectives('text');
All core API methods like `getAdjectives`, `getNouns`, `isAdjective`, etc., are asynchronous and expect a callback function as the last argument, or can be awaited if Promises are used (v1+).

This quickstart initializes WordPOS and demonstrates basic asynchronous part-of-speech tagging and word classification using callbacks.

const WordPOS = require('wordpos'); const wordpos = new WordPOS(); wordpos.getAdjectives('The angry bear chased the frightened little squirrel.', (result) => { console.log('Adjectives:', result); }); wordpos.isAdjective('awesome', (result) => { console.log('Is awesome an adjective?', result); }); // Demonstrating getPOS for all parts of speech wordpos.getPOS('The quick brown fox jumps over the lazy dog.', (result) => { console.log('All POS breakdown:', result); });
wordpos --version
Debug
Known issues
breakingVersion 1.x removed the direct dependency on the `natural` library's WordNet module, implementing its own fast lookup. Projects relying on `natural`'s specific WordNet behavior might require adjustments.
fix
Review WordPOS API for direct equivalents. If you need `natural`'s WordNet specifically, use `natural` directly or stick to `wordpos` pre-1.0.0.
affects: >=1.0.0
breakingVersion 2.x involved a total refactor to enable browser compatibility. While the API remains similar, internal changes might affect environments with specific build processes or require different asset loading strategies for the WordNet database.
fix
For browser usage, ensure your bundling setup handles the WordNet data files correctly, or consider using `wordpos-web` for a pre-optimized browser distribution. Test thoroughly after upgrading.
affects: >=2.0.0
gotchaAll API methods in wordpos are asynchronous. Failing to provide a callback function (or `await` a Promise in newer versions) will result in uncaught errors or unexpected behavior.
fix
Always pass a callback function as the last argument to methods like `getNouns`, `isAdjective`, `getPOS`, etc., or handle the returned Promise explicitly (e.g., `.then().catch()` or `await`).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: wordpos.getAdjectives is not a function
The WordPOS class was imported but not instantiated with `new WordPOS()`.
fix
Ensure you create an instance of the class: `const wordpos = new WordPOS();`
ReferenceError: require is not defined
Attempting to use CommonJS `require()` syntax in an ECMAScript Module (ESM) environment.
fix
Change your import statement to `import WordPOS from 'wordpos';` and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`).
Callback is not a function or missing
An asynchronous API method was called without providing a callback function.
fix
Provide a callback function as the last argument to all asynchronous API calls, e.g., `wordpos.getNouns('text', (result) => { /* handle result */ });`.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
32 hits · last 30 days
node
24
OpenAI (training)
1
Resources
wordpos — npm install wordpos · libregistry