0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GoogleColabratoryでMeCab+Neologdを使いたい

Posted at

はじめに

この記事は2021年10月にまとめていた「細かいつまずいたことをメモしておく(10月編)をそれぞれ投稿した内容になります
解決方法が最新でない可能性もありますのでご了承ください

手順

!apt-get -q -y install sudo file mecab libmecab-dev mecab-ipadic-utf8 git curl python-mecab > /dev/null
!git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd.git > /dev/null 
!echo yes | mecab-ipadic-neologd/bin/install-mecab-ipadic-neologd -n > /dev/null 2>&1
!pip install mecab-python3 > /dev/null
!ln -s /etc/mecabrc /usr/local/etc/mecabrc

ライブラリをインストールしたら以下で利用できることが確かめられる

import MeCab

m_t = MeCab.Tagger('-Ochasen -d /usr/lib/x86_64-linux-gnu/mecab/dic/mecab-ipadic-neologd')

text = '機械学習が好きです。'

print(m_t.parse(text))

また、Mecab.Taggerに渡している辞書のパスは以下のコマンドでみつけます

!echo `mecab-config --dicdir`"/mecab-ipadic-neologd"

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?