Registry / ai-ml / lindera-wasm-cc-cedict-bundler

lindera-wasm-cc-cedict-bundler

JSON →
library2.3.4jsnpmunverified

Lindera is a high-performance Rust-based morphological analysis library, compiled to WebAssembly (WASM) for use in JavaScript environments. This specific package, `lindera-wasm-cc-cedict-bundler`, provides Chinese morphological analysis capabilities utilizing the comprehensive CC-CEDICT dictionary. It is specifically designed and optimized for integration with JavaScript bundlers like Webpack, Rollup, or Vite, facilitating efficient tokenization and detailed linguistic analysis of Chinese text directly within web applications. The Lindera project generally maintains a regular release cadence, with major updates often reflecting enhancements in the core Rust library, improvements in WASM compilation targets, or dictionary updates. Key differentiators include its performance due to the WASM architecture, the availability of specialized dictionary sets via distinct npm packages, and a consistent API across different language analysis modules. Version 3.0.5 is the current stable release, offering robust and safe dictionary deserialization.

npm install lindera-wasm-cc-cedict-bundler
INSTALL
IMPORT
SIG · LINDERA-WASM-CC-CE
L
lindera-wasm-cc-cedict-bundler
ai-mljavascriptv2.3.4
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.

__wbg_init
import __wbg_init from 'lindera-wasm-cc-cedict-bundler';
const __wbg_init = require('lindera-wasm-cc-cedict-bundler');
This function initializes the WebAssembly module and must be called and awaited before any other functions from the library. Since v3, ESM is the primary module system for bundler targets.
TokenizerBuilder
import { TokenizerBuilder } from 'lindera-wasm-cc-cedict-bundler';
import TokenizerBuilder from 'lindera-wasm-cc-cedict-bundler';
TokenizerBuilder is a named export used to configure and construct a tokenizer instance. Avoid default import mistakes.
Token
import type { Token } from 'lindera-wasm-cc-cedict-bundler';
Import the Token type for TypeScript usage to ensure type safety when working with tokenized results.

Demonstrates how to initialize the WASM module, configure a tokenizer for Chinese with CC-CEDICT, and tokenize a sample Chinese sentence.

import __wbg_init, { TokenizerBuilder } from 'lindera-wasm-cc-cedict-bundler'; async function main() { // Initialize the WASM module. This is crucial and must be awaited. // Failure to await will result in runtime errors. await __wbg_init(); // Create a new tokenizer builder instance. const builder = new TokenizerBuilder(); // Specify the embedded CC-CEDICT dictionary for Chinese analysis. // The 'embedded://' prefix indicates a dictionary bundled with the package. builder.setDictionary("embedded://cc-cedict"); // Set the tokenization mode. Common modes include "normal", "decompose", "search". builder.setMode("normal"); // Build the tokenizer instance from the configured builder. const tokenizer = builder.build(); // Text to tokenize in Chinese. const text = "他们说汉语。"; // "They speak Chinese." // Tokenize the text into an array of tokens. const tokens = tokenizer.tokenize(text); // Process and log the tokens with their details. console.log(`Tokenizing "${text}":`); tokens.forEach(token => { // Each token object contains the surface form and an array of linguistic details. console.log(`- Surface: "${token.surface}", Details: [${token.details.join(", ")}]`); // Example details for Chinese might include Pinyin, part of speech, etc. }); } // Run the main function and catch any potential errors during execution. main().catch(console.error);
Debug
Known issues
breakingVersion 3.0.0 introduced significant internal changes, including a shift from unsafe DAAC deserialization to a safe method and improved error propagation in dictionary handling. While the package name `lindera-wasm-cc-cedict-bundler` itself persisted, these changes can affect runtime behavior and error handling logic, requiring review of existing code upon upgrade from v2.
fix
Review release notes for v3.0.0 and subsequent v3.x releases. Ensure error handling aligns with new propagation mechanisms. Verify dictionary loading and tokenization behavior in your application.
affects: >=3.0.0
gotchaThe WebAssembly module must be explicitly initialized by calling and awaiting the `__wbg_init()` function before any other functions from the package can be used. Failing to do so will result in runtime errors related to uninitialized WASM.
fix
Always call `await __wbg_init();` at the beginning of your application's entry point or before interacting with `TokenizerBuilder` and other library functions.
affects: >=1.0.0
gotchaWhen targeting bundlers and web environments, `lindera-wasm-*` packages are primarily designed for ES Module (ESM) imports. Using CommonJS `require()` syntax might lead to issues with bundlers or incorrect module resolution in modern JavaScript environments.
fix
Prefer `import ... from 'lindera-wasm-cc-cedict-bundler'` syntax. Ensure your bundler is configured to handle WASM modules and ESM correctly.
affects: >=3.0.0
gotchaThis specific package is pre-configured with the CC-CEDICT dictionary. When setting the dictionary, ensure you use `builder.setDictionary("embedded://cc-cedict")`. Using an incorrect or unsupported dictionary identifier will result in a dictionary not found error.
fix
Verify the dictionary identifier string matches the bundled dictionary, which for this package is `embedded://cc-cedict`.
affects: >=1.0.0
Errors
Common errors & fixes
Error: WASM module is not initialized.
The `__wbg_init()` function was not called or not awaited before attempting to use other library functions.
fix
Ensure `await __wbg_init();` is executed at the start of your application, usually in an async IIFE or your main setup function.
TypeError: TokenizerBuilder is not a constructor
This typically occurs if `__wbg_init()` has not completed, or if `TokenizerBuilder` is imported incorrectly (e.g., as a default import instead of named).
fix
Confirm `await __wbg_init();` has finished. Verify `import { TokenizerBuilder } from 'lindera-wasm-cc-cedict-bundler';` for correct named import.
Error: Dictionary not found: embedded://ipadic
Attempted to load a dictionary that is not bundled with this specific package. `lindera-wasm-cc-cedict-bundler` only contains the CC-CEDICT dictionary.
fix
Change the dictionary setting to `builder.setDictionary("embedded://cc-cedict");` to use the correct bundled dictionary.
ReferenceError: require is not defined
Attempting to use CommonJS `require()` syntax in a browser environment or a project configured for ESM only.
fix
Refactor your imports to use ES Modules syntax: `import ... from 'lindera-wasm-cc-cedict-bundler';`.
Upgrade
Version history
2.3.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources