MeCabを利用した日本語形態素解析WebAPI
文章を形態素に分割し、品詞や読みなどを取得できるJSON WebAPIを提供します。
形態素解析にはMeCabを利用しており、MeCabの分かち書きコストの計算結果も取得できます。
method:
GET or POST
path:
/text-analysis/v1/parse
/text-analysis/v1/reading
or
/v1/parse
/v1/reading
params:
sentence=<string>
nbest_num=<number> (not required)
- https://mecab-web-api.herokuapp.com/v1/parse?sentence=すもももももももものうち&nbest_num=2
- https://mecab-web-api.herokuapp.com/text-analysis/v1/reading?sentence=今日は良い天気だ
GET /text-analysis/v1/parse?sentence=エビフライ
or
GET /v1/parse?sentence=エビフライ
Takes a JSON object like this:
{
"items": [
{
"words": [
{
"word_cost": 4235,
"surface": "エビ",
"pos_detail1": "一般",
"pos": "名詞",
"conjugated_type": "",
"ime_romaji": "ebi",
"morpheme": "通常",
"conjugated_form": "",
"pos_detail3": "",
"c_cost": -283,
"pronunciation": "エビ",
"baseform": "エビ",
"reading": "エビ",
"pos_detail2": "",
"with_whitespace": false,
"cost": 3952
},
{
"word_cost": 3742,
"surface": "フライ",
"pos_detail1": "一般",
"pos": "名詞",
"conjugated_type": "",
"ime_romaji": "hurai",
"morpheme": "通常",
"conjugated_form": "",
"pos_detail3": "",
"c_cost": 62,
"pronunciation": "フライ",
"baseform": "フライ",
"reading": "フライ",
"pos_detail2": "",
"with_whitespace": false,
"cost": 3804
}
],
"all": {
"cost": 7756,
"wakati": "エビ フライ",
"length": 5,
"wakati_reading": "エビ フライ",
"normalized": "エビフライ",
"ime_romaji": "ebihurai",
"reading": "エビフライ"
}
},
{
"second cost analysis result"
},
"..."
],
"input_sentence": "エビフライ"
}
GET /text-analysis/v1/parse?sentence=今日は良い天気だ
or
GET /v1/parse?sentence=今日は良い天気だ
Takes a JSON object like this:
{
"items": [
{
"ignore_all_romaji": "kiyouhayoitennkita",
"romaji": "kixyouhayoitennkida",
"ignore_kogaki_romaji": "kiyouhayoitennkida",
"ignore_soundmark_romaji": "kixyouhayoitennkita",
"qwerty_romaji": "kixyouhayoitennkida",
"reading": "キョウハヨイテンキダ"
},
{
"ignore_all_romaji": "konnnitihayoitennkita",
"romaji": "konnnitihayoitennkida",
"ignore_kogaki_romaji": "konnnitihayoitennkida",
"ignore_soundmark_romaji": "konnnitihayoitennkita",
"qwerty_romaji": "konnnitihayoitennkida",
"reading": "コンニチハヨイテンキダ"
},
"..."
],
"input_sentence": "今日は良い天気だ"
}
using Docker Hub
$ sudo docker run -d -p 8000:8000 bungoume/mecab-web-api
or build container on yourself
$ git clone https://github.com/bungoume/mecab-web-api.git
$ sudo docker build -t mecab-web-api mecab-web-api
$ sudo docker run -d -p 8000:8000 mecab-web-api
then, access http://localhost:8000/static/demo.html