[PYTHON] ■ [Google Colaboratory] Use morphological analysis (MeCab)

1. How to install MeCab

Install MeCab with pip

!pip install mecab-python

2. Morphological analysis with MeCab

import MeCab
# Example 1
s = MeCab.Tagger('-Ochasen')
print(s.parse('There is a chicken in the haniwa'))

image.png

# Example 2
s = MeCab.Tagger('-Ochasen')
print(s.parse('There are two chickens in the yard'))

image.png

3. Comparison of morphological analysis results of MeCab and janome

3.1 Kanji / Hiragana / Katakana

Result of Analysis by MeCab(mecab-python3-0.996.5) image.png

Result of Analysis by janome(janome-0.3.10) image.png

3.2 Hiragana

It became a collaboration by "crocodile", "haniwa" and "chicken"

Result of Analysis by MeCab(mecab-python3-0.996.5) image.png

Result of Analysis by janome(janome-0.3.10) image.png

Reference

■ [Google Colaboratory] Preprocessing of Natural Language Processing & Morphological Analysis (janome) ■ [Google Colaboratory] Use morphological analysis (janome) Install Python from source What are configure, make, make install Do not install to / usr or / usr / local when building and installing software yourself

Recommended Posts

■ [Google Colaboratory] Use morphological analysis (MeCab)
■ [Google Colaboratory] Use morphological analysis (janome)
[Python] Morphological analysis with MeCab
Use music21 on Google Colaboratory
How to use Google Colaboratory
Google colaboratory
■ [Google Colaboratory] Preprocessing of Natural Language Processing & Morphological Analysis (janome)
I played with Mecab (morphological analysis)!
Use MeCab and neologd with Google Colab
Use The Metabolic Disassembler on Google Colaboratory
Use cartopy without bugs in Google Colaboratory
Use TPU and Keras with Google Colaboratory
Difference in morphological analysis results by mecab dictionary
Google Colaboratory 90-minute session disconnection countermeasures --- Use Python! ---
Morphological analysis tool installation (MeCab, Human ++, Janome, GiNZA)
Is it Google Colaboratory?
Collecting information from Twitter with Python (morphological analysis with MeCab)
[Morphological analysis] How to add a new dictionary to Mecab
How to use Spacy Japanese model in Google Colaboratory
I can't use the darknet command in Google Colaboratory!
Building an environment to use CaboCha with google colaboratory
Use MeCab to fetch readings
Python: Japanese text: Morphological analysis
Try StyleGAN on Google Colaboratory
Study Python with Google Colaboratory
Natural language processing 1 Morphological analysis
Google form aggregate analysis tool
Use Python's MeCab binding natto-py
Japanese morphological analysis with Python
Try OpenCV with Google Colaboratory
Tool organization: Google Colaboratory (updated 2020.2.24)
[PowerShell] Morphological analysis with SudachiPy
Pandas 100 knocks on Google Colaboratory
Make the morphological analysis engine MeCab available in Python 3 (March 2016 version)
How to use Google Colaboratory and usage example (PyTorch x DCGAN)
The strongest way to use MeCab and CaboCha with Google Colab