Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Async Japanese Tokenizer Native Plugin for React Native for iOS and Android

License

NotificationsYou must be signed in to change notification settings

craftzdog/react-native-japanese-tokenizer

Repository files navigation

Async Japanese tokenizer native plugin for React Native that works on iOS and Android.It tokenizes Japanese text in background thread so it won't block UI. It comes in handy for such as indexing a lot of texts for full-text search.

screenshot

How it works

iOS

It utilizesCFStringTokenizer to tokenize strings into words.

Android

The implementation is based onTinySegmenter. It is lightweight word segmenter which works without dictionaries.

Getting started

$ npm install react-native-japanese-tokenizer --save

Mostly automatic installation

$ react-native link react-native-japanese-tokenizer

Manual installation

iOS

  1. In XCode, in the project navigator, right clickLibrariesAdd Files to [your project's name]
  2. Go tonode_modulesreact-native-japanese-tokenizer and addRNJapaneseTokenizer.xcodeproj
  3. In Xcode, in the project navigator, select your project. AddlibRNJapaneseTokenizer.a to your project'sBuild PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)

Android

  1. Open upandroid/app/src/main/java/[...]/MainActivity.java
  • Addimport dog.craftz.japanese_tokenizer.RNJapaneseTokenizerPackage; to the imports at the top of the file
  • Addnew RNJapaneseTokenizerPackage() to the list returned by thegetPackages() method
  1. Append the following lines toandroid/settings.gradle:
    include ':react-native-japanese-tokenizer'project(':react-native-japanese-tokenizer').projectDir = new File(rootProject.projectDir,  '../node_modules/react-native-japanese-tokenizer/android')
  2. Insert the following lines inside the dependencies block inandroid/app/build.gradle:
     compile project(':react-native-japanese-tokenizer')

Usage

UsingPromise:

importTokenizerfrom'react-native-japanese-tokenizer'vartext="週休七日で働きたい"Tokenizer.tokenize(text).then(tokens=>{  ...})

async/await:

importTokenizerfrom'react-native-japanese-tokenizer'vartext="週休七日で働きたい"consttokens=awaitTokenizer.tokenize(text)

Also check outthe test to learn more.

License

MIT License. By Takuya Matsuyama (@craftzdog).

Note that this module is based on following libraries with respective license. Thank you for the fantastic works!

About

Async Japanese Tokenizer Native Plugin for React Native for iOS and Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp