lindera-wasm 1.1.0

A morphological analysis library for WebAssembly.
Documentation

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