Webアプリケーションに簡単に組み込めるJUMAN++のDockerイメージを作りました。
POSTで文字列を送ると形態素解析をした結果が返って来ます。
起動方法
docker run -d -p 4567:4567 gkmr/jumanpp-api
リクエスト方法
URL | 役割 |
---|---|
/split | 分かち書きした結果を返す |
/parse | 形態素解析した情報を返す |
/version | JUMANのバージョンを返す(jumanpp -v のレスポンス) |
FORM形式
curl -X POST --data 'string=この道をゆけばどうなるものか危ぶむなかれ危ぶめば道はなし踏み出せばその一足が道となりその一足が道となる迷わず行けよ行けば分かるさ' http://localhost:4567/split
JSON形式
curl -X POST -H 'Content-Type: application/json' --data '{"string":"この道をゆけばどうなるものか危ぶむなかれ危ぶめば道はなし踏み出せばその一足が道となり その一足が道となる迷わず行けよ行けば分かるさ"}' http://localhost:4567/split
レスポンス
/parse
{"status":"success","results":["この","道","を","ゆけば","どう","なる","もの","か","危ぶむ","なかれ","危ぶめば","道","は","なし","踏み出せば","その","一足","が","道","と","なり","その","一足","が","道","と","なる","迷わ","ず","行けよ","行けば","分かる","さ"]}
/parse
{"status":"success","elements":["表層形","読み","見出し語","品詞大分類","品詞大分類ID","品詞細分類","品詞細分類ID","活用型","活用型ID","活用形","活用形ID","意味情報"],"results":[["この","この","この","指示詞","7","連体詞形態指示詞","2","*","0","*","0","NIL"],["道","みち","道","名詞","6","普通名詞","1","*","0","*","0","代表表記:道/みち 漢字読み:訓 カテゴリ:場所-施設"],["を","を","を","助詞","9","格助詞","1","*","0","*","0","NIL"],["ゆけば","ゆけば","ゆく","動詞","2","*","0","子音動詞カ行","2","基本条件形","7","代表表記:行く/いく 付属動詞候補(基本) 付属動詞候補(タ系) ドメイン:交通 反義:動詞:帰る/かえる"],["どう","どう","どう","指示詞","7","副詞形態指示詞","3","*","0","*","0","NIL"],["なる","なる","なる","動詞","2","*","0","子音動詞ラ行","10","基本形","2","代表表記:鳴る/なる 自他動詞:他:鳴らす/ならす"],["もの","もの","もの","名詞","6","形式名詞","8","*","0","*","0","NIL"],["か","か","か","助詞","9","接続助詞","3","*","0","*","0","NIL"],["危ぶむ","あやぶむ","危ぶむ","動詞","2","*","0","子音動詞マ行","9","基本形","2","代表表記:危ぶむ/あやぶむ 補文ト"],["なかれ","なかれ","ない","接尾辞","14","形容詞性述語接尾辞","5","イ形容詞アウオ段","18","文語命令形","22","代表表記:ない/ない"],["危ぶめば","あやぶめば","危ぶむ","動詞","2","*","0","子音動詞マ行","9","基本条件形","7","代表表記:危ぶむ/あやぶむ 補文ト"],["道","みち","道","名詞","6","普通名詞","1","*","0","*","0","代表表記:道/みち 漢字読み:訓 カテゴリ:場所-施設"],["は","は","は","助詞","9","副助詞","2","*","0","*","0","NIL"],["なし","なし","ない","形容詞","3","*","0","イ形容詞アウオ段","18","文語基本形","18","代表表記:無い/ない 反義:動詞:有る/ある"],["踏み出せば","ふみだせば","踏み出す","動詞","2","*","0","子音動詞サ行","5","基本条件形","7","代表表記:踏み出す/ふみだす"],["その","その","その","指示詞","7","連体詞形態指示詞","2","*","0","*","0","NIL"],["一足","ひとあし","一足","名詞","6","普通名詞","1","*","0","*","0","代表表記:一足/ひとあし カテゴリ:数量;時間"],["が","が","が","助詞","9","格助詞","1","*","0","*","0","NIL"],["道","みち","道","名詞","6","普通名詞","1","*","0","*","0","代表表記:道/みち 漢字読み:訓 カテゴリ:場所-施設"],["と","と","と","助詞","9","格助詞","1","*","0","*","0","NIL"],["なり","なり","なる","動詞","2","*","0","子音動詞ラ行","10","基本連用形","8","代表表記:鳴る/なる 自他動詞:他:鳴らす/ならす"],["その","その","その","指示詞","7","連体詞形態指示詞","2","*","0","*","0","NIL"],["一足","ひとあし","一足","名詞","6","普通名詞","1","*","0","*","0","代表表記:一足/ひとあし カテゴリ:数量;時間"],["が","が","が","助詞","9","格助詞","1","*","0","*","0","NIL"],["道","みち","道","名詞","6","普通名詞","1","*","0","*","0","代表表記:道/みち 漢字読み:訓 カテゴリ:場所-施設"],["と","と","と","助詞","9","格助詞","1","*","0","*","0","NIL"],["なる","なる","なる","動詞","2","*","0","子音動詞ラ行","10","基本形","2","代表表記:鳴る/なる 自他動詞:他:鳴らす/ならす"],["迷わ","まよわ","迷う","動詞","2","*","0","子音動詞ワ行","12","未然形","3","代表表記:迷う/まよう"],["ず","ず","ぬ","助動詞","5","*","0","助動詞ぬ型","27","基本連用形","4","NIL"],["行けよ","いけよ","行ける","動詞","2","*","0","母音動詞","1","文語命令形","18","代表表記:行ける/いける 可能動詞:行く/いく 付属動詞候補(タ系) ドメイン:交通"],["行けば","いけば","行く","動詞","2","*","0","子音動詞カ行促音便形","3","基本条件形","7","代表表記:行く/いく 付属動詞候補(タ系) ドメイン:交通 反義:動詞:帰る/かえる"],["分かる","わかる","分かる","動詞","2","*","0","子音動詞ラ行","10","基本形","2","代表表記:分かる/わかる"],["さ","さ","さ","助詞","9","終助詞","4","*","0","*","0","NIL"]]}
/version
{"results":"JUMAN++ 1.02","status":"success"}
設定変更
内部では jumanpp_ruby
というgemを使用しており、config.ymlを作成して起動時に上書きすることで設定を変更することができます。
docker run -d -p 4567:4567 -v $(pwd)/config.yml:/var/app/current/config.yml gkmr/jumanpp-api
config.ymlの初期値
:beam: '5'
:force_single_path: true
:partial: true