Skip to content

bungoume/mecab-web-api

Repository files navigation

mecab-web-api

Circle CI Coverage Status Requirements Status License

MeCabを利用した日本語形態素解析WebAPI

typography-icon

Description

文章を形態素に分割し、品詞や読みなどを取得できるJSON WebAPIを提供します。

形態素解析にはMeCabを利用しており、MeCabの分かち書きコストの計算結果も取得できます。

HTTP API

Endpoints

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)

Demo

Sample Response

parse API

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": "エビフライ"
}

reading API

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": "今日は良い天気だ"
}

Quick Start

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

Licence

MIT

Author

bungoume

About

MeCabを利用した日本語形態素解析WebAPI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •