Help us understand the problem. What is going on with this article?

誰でも簡単にWikipediaからword2vecを生成できるツール

More than 1 year has passed since last update.

Wikipediaのダンプからword2vecを生成するやり方を知らない初心者がいると思ったので、Ubuntu上で簡単に実行できるスクリプトを作成したので紹介します。

jawiki2w2v

jawiki dumpのURLを渡せばText8とword2vecを生成してくれるツール。
https://github.com/sugiyamath/jawiki2w2v

事前準備

MeCabとneologdを入れる

git clone https://github.com/taku910/mecab && \
    cd mecab/mecab && \
    ./configure --enable-utf8-only && \
    make && \
    make check && \
    make install && \
    pip install --no-cache-dir mecab-python3 && \
    ldconfig && \
    cd ../mecab-ipadic && \
    ./configure --with-charset=utf8 && \
    make && \
    make install
git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd && \
    pushd mecab-ipadic-neologd && \
    yes yes | ./bin/install-mecab-ipadic-neologd -n && \
    popd && \
    yes | rm -r mecab-ipadic-neologd

pythonモジュールを入れる

pip install gensim tqdm beautifulsoup4 mecab-python3

使い方

Usage: ./wiki2w2v.sh <wiki dump url> [neologd path]

例:

git clone https://github.com/sugiyamath/jawiki2w2v
cd jawiki2w2v
./wiki2w2v.sh https://dumps.wikimedia.org/jawiki/latest/jawiki-latest-pages-articles.xml.bz2

注意点

スクリプト全体の実行時間が結構掛かるため、全体のテストが不完全です。もしバグを見つけたらgithubのissueに残していただくか、自分で修正していただけると良いかと思います。

このスクリプトの目的は、自然言語処理の初心者が、コードを見て「wikipediaダンプからword2vecをどのように生成するのか」を学ぶために作成しています。

sugiyamath
ブログ "ナード戦隊データマン" を書いている人。
http://datanerd.hateblo.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした