{"id":17408,"library":"wordpos","title":"Part-of-Speech Tagger with WordNet","description":"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.","status":"active","version":"2.1.0","language":"javascript","source_language":"en","source_url":"git://github.com/moos/wordpos","tags":["javascript","natural","language","wordnet","adjectives","nouns","adverbs","verbs"],"install":[{"cmd":"npm install wordpos","lang":"bash","label":"npm"},{"cmd":"yarn add wordpos","lang":"bash","label":"yarn"},{"cmd":"pnpm add wordpos","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"WordPOS is a default export representing the main class for POS operations. Named imports will fail.","wrong":"import { WordPOS } from 'wordpos';","symbol":"WordPOS","correct":"import WordPOS from 'wordpos';"},{"note":"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.","wrong":"import WordPOS from 'wordpos';","symbol":"WordPOS","correct":"const WordPOS = require('wordpos');"},{"note":"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+).","wrong":"wordpos.getAdjectives('text');","symbol":"wordpos.getAdjectives","correct":"wordpos.getAdjectives('text', callback);"}],"quickstart":{"code":"const WordPOS = require('wordpos');\nconst wordpos = new WordPOS();\n\nwordpos.getAdjectives('The angry bear chased the frightened little squirrel.', (result) => {\n    console.log('Adjectives:', result);\n});\n\nwordpos.isAdjective('awesome', (result) => {\n    console.log('Is awesome an adjective?', result);\n});\n\n// Demonstrating getPOS for all parts of speech\nwordpos.getPOS('The quick brown fox jumps over the lazy dog.', (result) => {\n    console.log('All POS breakdown:', result);\n});","lang":"javascript","description":"This quickstart initializes WordPOS and demonstrates basic asynchronous part-of-speech tagging and word classification using callbacks."},"warnings":[{"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.","message":"Version 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.","severity":"breaking","affected_versions":">=1.0.0"},{"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.","message":"Version 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.","severity":"breaking","affected_versions":">=2.0.0"},{"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`).","message":"All 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure you create an instance of the class: `const wordpos = new WordPOS();`","cause":"The WordPOS class was imported but not instantiated with `new WordPOS()`.","error":"TypeError: wordpos.getAdjectives is not a function"},{"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`).","cause":"Attempting to use CommonJS `require()` syntax in an ECMAScript Module (ESM) environment.","error":"ReferenceError: require is not defined"},{"fix":"Provide a callback function as the last argument to all asynchronous API calls, e.g., `wordpos.getNouns('text', (result) => { /* handle result */ });`.","cause":"An asynchronous API method was called without providing a callback function.","error":"Callback is not a function or missing"}],"ecosystem":"npm","meta_description":null}