Kuromoji.js is a JavaScript implementation of a Japanese morphological analyzer, directly ported from the Java-based Kuromoji project. It provides functionality to tokenize Japanese text into its constituent words (morphemes) and extract detailed information such as part-of-speech tags, base forms, readings (pronunciation in Katakana), and surface forms. The package's current stable version is `0.1.2`, and its last known publication date was approximately eight years ago (around March 2018), indicating that the original project is largely abandoned or unmaintained. It primarily supports CommonJS modules for Node.js environments and global script inclusion for browsers, relying exclusively on callback-based asynchronous operations for dictionary loading. Due to its age, it lacks modern JavaScript features like ESM support, TypeScript definitions, and Promise-based APIs. Developers seeking these modern capabilities should consider using actively maintained forks such as `@patdx/kuromoji` or `code4fukui-es`, which offer updated architectures and features.
npm install kuromojiVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to initialize the Kuromoji.js tokenizer in Node.js, specifying the dictionary path, and then tokenize a Japanese sentence.
For new projects or modern environments, consider using actively maintained forks such as `@patdx/kuromoji` or `code4fukui-es`, which offer ESM, Promises, and TypeScript support.
Ensure `dicPath` points to the *exact* directory containing the gzipped dictionary files (e.g., `node_modules/kuromoji/dict` for npm installations in Node.js, or a correct CDN path for browsers). Use `path.resolve` in Node.js for robust path handling.
For browser usage, either serve the `build/kuromoji.js` and `dict/*.dat.gz` files from your application or a CDN, or consider using a modern fork which typically provides better browser integration and bundling support via npm.
In a browser, ensure `<script src="url/to/kuromoji.js"></script>` appears before your script that uses `kuromoji`. In Node.js, ensure `var kuromoji = require('kuromoji');` is at the top of your module.Verify that `dicPath` is an absolute or correct relative path to where the `dict` folder (containing `base.dat.gz`, `tid.dat.gz`, etc.) is located. For npm installations, this is often `path.resolve(__dirname, 'node_modules/kuromoji/dict')` in Node.js.
No dependency data recorded yet.