Code Monkey home page Code Monkey logo

mecab-service's Introduction

MeCab Webサービス

docker-composeコマンドだけで起動できるMeCabサービス

  • flask-mecab

    • MeCabを利用できるRESTfulなflaskサーバー
    • IPA辞書と新語辞書mecab-ipadic-neologdが選択できる
  • flask-mecab-front

    • flask-mecabのAPIを呼び出すフロントエンドアプリ
    • 環境:Flask, Vue.js, Bootstrap3

ディレクトリ構成

.
├── docker-compose.yml
├── flask-mecab
│   ├── Dockerfile
│   ├── requirements.txt
│   └── server.py
├── flask-mecab-front
│   ├── app.py
│   ├── Dockerfile
│   ├── requirements.txt
│   ├── static
│   │   ├── app.js
│   │   └── style.css
│   └── templates
│       ├── index.html
│       └── layout.html
└── README.md

起動方法/終了方法

$ docker-compose up -d
$ docker-compose down

実行方法

HTTPリクエスト

POST /mecab/v1/parse-ipadic
POST /mecab/v1/parse-neologd

リクエストヘッダ

Content-Type: application/json

リクエストボディ

{
  "sentence": 文字列
}

実行例 ipadic

$ curl -X POST http://localhost:5000/mecab/v1/parse-ipadic \
       -H "Content-type: application/json" \
       -d '{"sentence": "関数型プログラミング"}'  | jq .
{
  "dict": "ipadic",
  "message": "Success",
  "results": [
    {
      "原型": "関数",
      "品詞": "名詞",
      "品詞細分類1": "一般",
      "品詞細分類2": "*",
      "品詞細分類3": "*",
      "活用型": "*",
      "活用形": "*",
      "発音": "カンスー",
      "表層形": "関数",
      "読み": "カンスウ"
    },
    {
      "原型": "",
      "品詞": "名詞",
      "品詞細分類1": "接尾",
      "品詞細分類2": "一般",
      "品詞細分類3": "*",
      "活用型": "*",
      "活用形": "*",
      "発音": "ガタ",
      "表層形": "",
      "読み": "ガタ"
    },
    {
      "原型": "プログラミング",
      "品詞": "名詞",
      "品詞細分類1": "サ変接続",
      "品詞細分類2": "*",
      "品詞細分類3": "*",
      "活用型": "*",
      "活用形": "*",
      "発音": "プログラミング",
      "表層形": "プログラミング",
      "読み": "プログラミング"
    }
  ],
  "status": 200
}

実行例 mecab-ipadic-neologd

mecab-ipadic-neologdは固有名詞に強い辞書です。

$ curl -X POST http://localhost:5000/mecab/v1/parse-neologd \
       -H "Content-type: application/json" \
       -d '{"sentence": "関数型プログラミング"}'  | jq .
{
  "dict": "neologd",
  "message": "Success",
  "results": [
    {
      "原型": "関数型プログラミング",
      "品詞": "名詞",
      "品詞細分類1": "固有名詞",
      "品詞細分類2": "一般",
      "品詞細分類3": "*",
      "活用型": "*",
      "活用形": "*",
      "発音": "カンスーガタプログラミング",
      "表層形": "関数型プログラミング",
      "読み": "カンスウガタプログラミング"
    }
  ],
  "status": 200
}

フロントエンド

ブラウザでhttp://localhost:5001/にアクセスします。

スクリーンショット

mecab.PNG

mecab-service's People

Contributors

eiurur avatar matsulib avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mecab-service's Issues

セットアップ時にswigが無いと言われました

NeoLogdのインストールの途中で、以下のようなエラーが出ましたので、
flask-mecabのDockerfile のapt-get にswig を追加したらうまく動きましたので、ご報告いたします。

エラー内容
unable to execute 'swig': No such file or directory
error: command 'swig' failed with exit status 1
Running setup.py clean for mecab-python3
Failed building wheel for mecab-python3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.