
Research
/Security News
DuckDB npm Account Compromised in Continuing Supply Chain Attack
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
dev.natsuume.knp4j:knp4j
Advanced tools
This is the wrapper that call KNP( Japanese morpheme, dependency, case analyzer ) in Java.
JUMAN(JUMAN++)、KNPのプロセスをJavaから実行して結果を取得するライブラリです。
https://search.maven.org/artifact/dev.natsuume/knp4j
<dependency>
<groupId>dev.natsuume.knp4j</groupId>
<artifactId>knp4j</artifactId>
<version>1.1.3</version>
</dependency>
implementation 'dev.natsuume.knp4j:knp4j:1.1.3'
下記のように使用することができます。
各種オプションのうちParserの設定は必須です。
また、それ以外のオプションについては下記例の内容がデフォルトで使用されます。
//KNPWrapperを作成するためのBuilder
ResultParser<KnpResult> knpResultParser = new KnpResultParser();
KnpWrapperBuilder<KnpResult> knpWrapperBuilder = new KnpWrapperBuilder<>();
KnpWrapper<KnpResult> wrapper = knpWrapperBuilder
.setJumanCommand(List.of("bash", "-c", "jumanpp")) //Jumanの実行コマンド
.setKnpCommand(List.of("bash", "-c", "knp -tab -print-num -anaphora")) //KNPの実行コマンド(現在は「-tab」「-print-num」「-anaphora」オプション必須)
.setJumanMaxNum(1) //同時に起動するJumanの最大プロセス数
.setJumanStartNum(1) //初期化時に起動するJumanのプロセス数
.setKnpMaxNum(1) //同時に起動するKNPの最大プロセス数
.setKnpStartNum(1) //初期化時に起動するKNPのプロセス数
.setRetryNum(0) //結果の取得に失敗した場合にリトライする回数
.setResultParser(knpResultParser) //出力結果のList<String>を任意のクラスに変換するParserを設定する
.start();
var texts = List.of(
"テストテキスト1です",
"テストテキスト2です",
"テストテキスト3です"
);
texts.parallelStream().map(wrapper::analyze)
.flatMap(List::stream)
.map(KnpResult::getSurfaceForm)
.forEach(System.out::println);
現在KNPの解析結果ParserとしてKnpResultParserのみ実装されています。
KnpResultは下記メソッドを持ちます。
/**
* 文節のリストを返す.
*
* @return 文節の一覧
*/
List<KnpClause> getClauses();
/**
* 形態素のリストを返す.
*
* @return 形態素の一覧
*/
List<KnpMorpheme> getMorphemes();
/**
* 基本句のリストを返す.
*
* @return 基本句の一覧
*/
List<KnpPhrase> getPhrases();
/**
* 文末の文節を返す. 要素が存在しないときはnullを返す.
*
* @return 文末のKnpClause
*/
KnpClause getRootNode();
/**
* KNPの出力結果の文字列リストを返す.
*
* @return 出力結果
*/
List<String> getRawResultData();
/**
* 入力された表層文字列を返す.
*
* @return 入力文字列
*/
String getSurfaceForm();
/**
* 解析スコアを返す.
*
* @return 解析スコア
*/
double getScore();
/**
* 正常な解析結果かどうかを返す.
*
* @return 正常な解析結果かどうか
*/
boolean isValid();
なお現在、JUMAN, KNPについてサーバモードでの起動は対応していません。
このソフトウェアは下記を使用しています。
これらのライセンス条項はLICENSEにあります。
このソフトウェアはソースコードのFormatにcheckstyleのgoogle_checks.xmlを利用しています。
上記ファイルのライセンス条項はcheckstyle_LICENSEにあります。
POSTPOSITIONAL_PARTICLE
を追加#
が含まれる場合にKnpResultBuilderがparsingに失敗する問題を修正-anaphora
オプションを削除FAQs
This is the wrapper that call KNP( Japanese morpheme, dependency, case analyzer ) in Java.
We found that dev.natsuume.knp4j:knp4j demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.