lindera-wasm

Crates.iolindera-wasm
lib.rslindera-wasm
version1.1.0
created_at2025-04-01 12:42:08.286082+00
updated_at2025-09-13 14:00:17.663779+00
descriptionA morphological analysis library for WebAssembly.
homepagehttps://github.com/lindera/lindera-wasm
repositoryhttps://github.com/lindera/lindera-wasm
max_upload_size
id1614797
size226,362
Minoru OSUKA (mosuka)

documentation

https://docs.rs/lindera-wasm

README

lindera-wasm

WebAssembly of Lindera

Screenshot

Demo Application

npm

Usage

init the wasm module before construct TokenizerBuilder:

import __wbg_init, { TokenizerBuilder } from 'lindera-wasm'

__wbg_init.then(() => {
    const builder = new TokenizerBuilder()
    //...
})

for Vite base project

You should exclude this package in the optimizeDeps:

// vite.config.js
import { defineConfig } from 'vite'

export default defineConfig({
  optimizeDeps: {
    exclude: [
      "lindera-wasm"
    ]
  },
})

for Browser extension development

Set the cors config in vite.config.js

// vite.config.js
import { defineConfig } from 'vite'

export default defineConfig({
  server: {
    cors: {
      origin: [
        /chrome-extension:\/\//,
      ],
    },
  },
})

and set the content_security_policy to contains wasm-unsafe-eval in manifest.json:

// manifest.json
"content_security_policy": {
	"extension_pages": "script-src 'self' 'wasm-unsafe-eval';"
}

Development

Install project dependencies

Setup repository

# Clone lindera-py project repository
% git clone git@github.com:lindera/lindera-wasm.git
% cd lindera-wasm

Build project

% wasm-pack build --release --features=cjk --target=bundler

Build example web application

% cd lindera-wasm && npm install && npm run build && cp index.html dist/index.html

Run example web application

% cd lindera-wasm && npm run start
Commit count: 67

cargo fmt