wikiコーパスのダウンロード
$ curl https://dumps.wikimedia.org/jawiki/latest/jawiki-latest-pages-articles.xml.bz2 -o jawiki-latest-pages-articles.xml.bz2
xml形式なので、テキストを抜き出す。
そういったプログラムを用意してくださっているので利用する。
$ git clone https://github.com/attardi/wikiextractor
実行
$ python wikiextractor/WikiExtractor.py jawiki-latest-pages-articles.xml.bz2
抽出された内容はフォルダに分けられるので、catで1つのファイルにまとめる
$ cat text/*/* > jawiki_org.txt
内容に<documetn ...>とあったり、空白行があったりするのでトリミング
$ cat ./jawiki_org.txt | sed -e 's/<.*>//g' | sed -e '/^ *$/d' > ./jawiki.txt
必要あればmecabで分かち書き
$ mecab -d /usr/local/lib/mecab/dic/mecab-ipadic-neologd/ -Owakati jawiki.txt > jawiki_wakachi.txt
以上の操作で完了
0 件のコメント:
コメントを投稿