An open API service indexing awesome lists of open source software.

https://github.com/rikeda71/morphanalysisapi

Japanese Morph Analysis Web API
https://github.com/rikeda71/morphanalysisapi

morphological-analysis

Last synced: 10 days ago
JSON representation

Japanese Morph Analysis Web API

Awesome Lists containing this project

README

          

# MorphAnalysisAPI

以下の3つの形態素解析機をWebAPIで試せるようにしたもの

- [MeCab](https://taku910.github.io/mecab/)
- mecab with [NEologd](https://github.com/neologd/mecab-ipadic-neologd)
- [JUMAN++](http://nlp.ist.i.kyoto-u.ac.jp/index.php?JUMAN++)
- [Sudachi](https://github.com/WorksApplications/SudachiPy) (SudachiPy)

## 必要なもの

- python3
- requests
- Docker

## 使い方

### Docker Containerの起動

```shell
docker build . -t morph-analysis-api # wait a minute
docker run -it --rm -d -p 5000:5000 -v $PWD/:/app morph-analysis-api:latest python app.py
```

### Docker Containerの停止(削除)

```shell
docker stop `container_id`
```

### 形態素解析のテスト

```shell
python3 request.py
```

#### テスト用スクリプトの詳細

```shell
python3 request.py -h
usage: request.py [-h] [-s SENTENCE]
[-m {mecab,mecab-neologd,sudachi,jumanpp}]

optional arguments:
-h, --help show this help message and exit
-s SENTENCE, --sentence SENTENCE
a japanese sentence. default=`すもももももももものうち`
-m {mecab,mecab-neologd,sudachi,jumanpp}, --machine {mecab,mecab-neologd,sudachi,jumanpp}
choice morphological analysis machine. default=`mecab`
```

### APIの仕様

| HTTP method | end point | request parameters | request headers |
---- | ---- | ---- | ----
| POST | /mecab | sentence | Content-Type:application/json |
| POST | /mecab-neologd | sentence | Content-Type:application/json |
| POST | /jumanpp | sentence | Content-Type:application/json |
| POST | /sudachi | sentence, mode [optional. 'A', 'B', or 'C'] | Content-Type:application/json |