jnlp
Japanese Natural Language Processing (JNLP) provides Japanese morphological analysis and tokenization as reusable Drupal services. It is a foundation library that other modules can build on to process Japanese text — for example, to power accurate Japanese search.
Japanese text has no spaces between words, so many text-processing tasks (search indexing, keyword extraction, reading generation) require natural language processing to split sentences into meaningful words. JNLP integrates proven Japanese analyzers behind a single, stable Drupal API.
Features
- A standardized, stateless service API:
process($text)returns an immutable result object with tokens and morphemes (surface form, part of speech, base form, normalized form). - Four interchangeable analyzers, each in its own submodule:
- JNLP MeCab — fast and widely used morphological analyzer (external binary).
- JNLP Sudachi — modern analyzer with word normalization and selectable split modes A/B/C (Java).
- JNLP Igo — pure PHP morphological analyzer, no server binaries required.
- JNLP TinySegmenter — compact pure PHP tokenizer using machine learning.
- Admin test forms for each analyzer, so you can verify your setup and inspect tokenization results without writing code.
- Availability checks (
isExecutable()/isAvailable()) so consuming modules can degrade gracefully when an analyzer is not installed.
Use JNLP when a module needs Japanese word segmentation or morphological data, such as search tokenization (see Search API Japanese Tokenizer), reading/furigana generation, or keyword extraction.
Post-Installation
- Enable the JNLP module and the submodule(s) for the analyzer you want to use.
- For MeCab and Sudachi, configure the analyzer paths in
settings.php(for security these are not editable in the UI), e.g.$settings['jnlp_sudachi_jar_path'] = '/opt/sudachi/sudachi-0.7.5.jar';. Igo and TinySegmenter need no configuration. - Verify your setup with the test forms under Configuration → Japanese Natural Language Processing (
/admin/config/jnlp): enter Japanese text and inspect the tokens each analyzer produces. - Sudachi's split mode (A/B/C) can be set at
/admin/config/jnlp/sudachi/settings.
Access to the administration pages is controlled by the Administer Japanese Natural Language Processing permission (restricted access).
Additional Requirements
Requirements depend on the analyzer you choose:
- MeCab: the MeCab binary and a dictionary on the server (e.g.
apt-get install mecab mecab-ipadic-utf8). - Sudachi: a Java Runtime Environment, the Sudachi JAR and a Sudachi dictionary.
- Igo: the
logue/igo-phpComposer package (bundled IPA dictionary included). - TinySegmenter: the
u7aro/tinysegmenter-phpComposer package.
Recommended modules/libraries
- Search API Japanese Tokenizer — Japanese search tokenization for Search API, built on JNLP.
Supporting this Module
Development is supported by Studio Umi, Inc. Issues and merge requests are welcome in the issue queue.
Community Documentation
- The module README (English and Japanese) covers installation,
settings.phpconfiguration, the developer API with code examples, and the API stability policy.
日本語の説明 (For Japanese)
Japanese Natural Language Processing (JNLP) は、日本語の形態素解析と分かち書き(トークナイゼーション)を再利用可能なDrupalサービスとして提供する基盤ライブラリモジュールです。他のモジュールから日本語テキスト処理機能を利用でき、例えば精度の高い日本語検索の実装に活用できます。
日本語は単語間にスペースがないため、検索インデックス作成・キーワード抽出・読み仮名生成といった多くのテキスト処理で、文章を意味のある単語に分割する自然言語処理が必要になります。JNLPは実績のある日本語解析器を、共通のDrupal APIを通じて利用できるようにします。
機能
- 標準化されたサービスAPI:
process($text)がトークンと形態素(表層形・品詞・基本形・正規化語)を含む結果オブジェクトを返します。 - 差し替え可能な4つの解析器(それぞれ独立したサブモジュール):
- JNLP MeCab — 高速で広く使われている形態素解析器(外部バイナリ)。
- JNLP Sudachi — 単語の正規化と分割モードA/B/Cの選択に対応したモダンな解析器(Java)。
- JNLP Igo — 純粋PHP実装の形態素解析器。サーバーへのバイナリ導入が不要です。
- JNLP TinySegmenter — 機械学習を用いたコンパクトな純粋PHPトークナイザー。
- 解析器ごとの管理テストフォーム。コードを書かずにセットアップの検証とトークナイズ結果の確認ができます。
- 可用性チェック(
isExecutable()/isAvailable())により、利用側モジュールは解析器が未導入の環境で機能を無効化するなどの対応ができます。
検索のトークナイズ(Search API Japanese Tokenizer 参照)や読み仮名の生成、キーワード抽出など、日本語の分かち書きや形態素データが必要な場面で利用できます。
インストール後の設定
- JNLPモジュールと、使用したい解析器のサブモジュールを有効化します。
- MeCabとSudachiは、解析器のパスを
settings.phpで設定します(セキュリティ上の理由でUIからは設定できません)。例:$settings['jnlp_sudachi_jar_path'] = '/opt/sudachi/sudachi-0.7.5.jar';。IgoとTinySegmenterは設定不要です。 - 環境設定 → Japanese Natural Language Processing(
/admin/config/jnlp)配下のテストフォームで、日本語テキストを入力して各解析器のトークナイズ結果を確認できます。 - Sudachiの分割モード(A/B/C)は
/admin/config/jnlp/sudachi/settingsで設定できます。
管理ページへのアクセスは Administer Japanese Natural Language Processing 権限(制限付きアクセス)で制御されます。
追加要件
要件は選択する解析器によって異なります:
- MeCab: サーバー上のMeCabバイナリと辞書(例:
apt-get install mecab mecab-ipadic-utf8)。 - Sudachi: Java実行環境(JRE)、Sudachi JAR、Sudachi辞書。
- Igo: Composerパッケージ
logue/igo-php(IPA辞書同梱)。 - TinySegmenter: Composerパッケージ
u7aro/tinysegmenter-php。
推奨モジュール
- Search API Japanese Tokenizer — JNLPの上に構築された、Search API向け日本語検索トークナイゼーション。
サポート
開発はスタジオ・ウミ株式会社の支援を受けています。イシューやマージリクエストはイシューキューまでお寄せください。
ドキュメント
- モジュールのREADME(英語・日本語)に、インストール手順、
settings.phpの設定、コード例付きの開発者向けAPI、API安定性ポリシーを記載しています。