[PYTHON] Use MeCab and neologd with Google Colab

Conclusion

Execute the following command.

!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
!echo `mecab-config --dicdir`"/mecab-ipadic-neologd"

How to use

import MeCab

path = "-d /usr/lib/x86_64-linux-gnu/mecab/dic/mecab-ipadic-neologd"
tagger = MeCab.Tagger(path)
text = 'Devil's blade is in vogue.'
node = tagger.parseToNode(text)
while node:
    print(node.feature)
    node = node.next

#Below, the output result
# BOS/EOS,*,*,*,*,*,*,*,*
#noun,Proprietary noun,General,*,*,*,Devil's Blade,Kimetsu no Yaiba,Kimetsu no Yaiba
#symbol,Comma,*,*,*,*,、,、,、
#verb,Independence,*,*,Five steps, La line,Continuous connection,Popular,Haya,Haya
#verb,Non-independent,*,*,One step,Uninflected word,Teru,Teru,Teru
#symbol,Punctuation,*,*,*,*,。,。,。
# BOS/EOS,*,*,*,*,*,*,*,*

The following information can be obtained from node.

--surface: split word --posid: Part of speech ID --feature: Detailed information

reference

Recommended Posts

Use MeCab and neologd with Google Colab
The strongest way to use MeCab and CaboCha with Google Colab
Use TPU and Keras with Google Colaboratory
Use Python and MeCab with Azure Functions
Use mecab with Python3
Learn with Shogi AI Deep Learning on Mac and Google Colab Use Google Colab
About learning with google colab
Deep Learning with Shogi AI on Mac and Google Colab
■ [Google Colaboratory] Use morphological analysis (MeCab)
Play with Turtle on Google Colab
Deep Learning with Shogi AI on Mac and Google Colab Chapter 11
Deep Learning with Shogi AI on Mac and Google Colab Chapters 1-6
Deep Learning with Shogi AI on Mac and Google Colab Chapter 8
Deep Learning with Shogi AI on Mac and Google Colab Chapter 12 3
Deep Learning with Shogi AI on Mac and Google Colab Chapter 7
Deep Learning with Shogi AI on Mac and Google Colab Chapter 10 6-9
Deep Learning with Shogi AI on Mac and Google Colab Chapter 10
Deep Learning with Shogi AI on Mac and Google Colab Chapter 7 5-7
Deep Learning with Shogi AI on Mac and Google Colab Chapter 9
Deep Learning with Shogi AI on Mac and Google Colab Chapter 12 3
Deep Learning with Shogi AI on Mac and Google Colab Chapter 12 3
Deep Learning with Shogi AI on Mac and Google Colab Chapter 12 1-2
Deep Learning with Shogi AI on Mac and Google Colab Chapter 12 3
Deep Learning with Shogi AI on Mac and Google Colab Chapter 12 3 ~ 5
Deep Learning with Shogi AI on Mac and Google Colab Chapter 7 9
Deep Learning with Shogi AI on Mac and Google Colab Chapter 8 5-9
Deep Learning with Shogi AI on Mac and Google Colab Chapter 8 1-4
Deep Learning with Shogi AI on Mac and Google Colab Chapter 12 3
Deep Learning with Shogi AI on Mac and Google Colab Chapter 7 8
Deep Learning with Shogi AI on Mac and Google Colab Chapter 7 1-4
How to use mecab, neologd-ipadic on colab
Using Python and MeCab with Azure Databricks
Use Jupyter Lab and Jupyter Notebook with EC2
Execute Google Translate and DeepL Translate with GUI
Use PIL and Pillow with Cygwin Python
Tweet analysis with Python, Mecab and CaboCha
Machine learning with Pytorch on Google Colab
Easy! Use gensim and word2vec with MAMP.
Feel free to knock 100 data sciences with Google Colab and Azure Notebooks!
How to use VS Code (code server) with Google Colab in just 3 lines
Deep Learning on Mac and Google Colab Words Learned with Shogi AI
Use dein.vim and ckw-mod with Windows7 32bit PowerShell
Try running Google Chrome with Python and Selenium
Display Google Maps API with Rails and pin display
Until you use the Kaggle API with Colab
How to use Service Account OAuth and API with Google API Client for python
Use Python and word2vec (learned) with Azure Databricks
Cheat sheet when scraping with Google Colaboratory (Colab)
Easy way to scrape with python using Google Colab
Book registration easily with Google Books API and Rails
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
Use of Google Cloud Storage (GCS) with "GAE / Py"
Install tweepy with pip and use it for API 1.1
Building an environment to use CaboCha with google colaboratory
Authenticate Google with Django
Use mecab-ipadic-neologd with igo-python
Use RTX 3090 with PyTorch
Use ansible with cygwin
Use pipdeptree with virtualenv
[Python] Use JSON with Python
Use Mock with pytest