LoginSignup
5
10

More than 5 years have passed since last update.

Dockerでdoc2vecを試すためのDockerfile

Posted at

概要

pythonでのdoc2vecをDocker上で試してみるためのDockerfileです。(自分用メモ)
doc2vecのほかに下記パッケージをインストールします。

  • Mecab
  • mecab-ipadic-neologd

Dockerfile

FROM python:3.6.4-slim-stretch

RUN apt-get update && \
    apt-get -y install sudo \
    git \
    gcc \
    g++ \
    make \
    curl \
    xz-utils \
    liblzma-dev \
    file \
    mecab-ipadic \
    mecab-ipadic-utf8

RUN mkdir -p /opt/downloads && \
    cd /opt/downloads && \
    git clone https://github.com/taku910/mecab.git && \
    git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd.git

RUN cd /opt/downloads/mecab/mecab && \
    ./configure  --enable-utf8-only && \
    make && \
    make check && \
    make install

RUN apt-get -y install 
RUN cd /opt/downloads/mecab-ipadic-neologd && \
    ./bin/install-mecab-ipadic-neologd -n -y

RUN pip install gensim mecab-python3

WORKDIR /usr/src/app/

ENTRYPOINT tail -f /dev/null

pythonスクリプト

コンテナが作成出来たらコンテナ内に入り、下記のような感じのスクリプトを実行できるはずです。

app.py
import MeCab
from gensim.models.doc2vec import Doc2Vec
from gensim.models.doc2vec import TaggedDocument

mecab = MeCab.Tagger('-Owakati -d /usr/local/lib/mecab/dic/mecab-ipadic-neologd')

#  …(略)…

5
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
10