[PYTHON] The strongest way to use MeCab and CaboCha with Google Colab

I don't know if it's actually the strongest, but the way I think it's this

It works by copying to the code cell of Google Colab (probably). It will take some time for make, so let's have a cup of coffee and wait ☕️

Gist source code

google_colab.ipynb


%%bash
#mecab and mecab-Install python3 dependencies
apt-get install mecab swig libmecab-dev mecab-ipadic-utf8
# mecab-python installation
pip install mecab-python3

#crfpp download(cabocha dependencies)
curl -sL -o CRF++-0.58.tar.gz "https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7QVR6VXJ5dWExSTQ"
tar -zxf CRF++-0.58.tar.gz
#crfpp installation
cd CRF++-0.58
./configure && make && make install && ldconfig
cd ..

#cabocha download
url="https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7SDd1Q1dUQkZQaUU"
curl -sc /tmp/cookie ${url} >/dev/null
code="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"
curl -sLb /tmp/cookie ${url}"&confirm=${code}" -o cabocha-0.69.tar.bz2
tar -jxf cabocha-0.69.tar.bz2
#cabocha installation
cd cabocha-0.69
./configure -with-charset=utf-8 && make && make check && make install && ldconfig
# cabocha-python installation
pip install python/
cd ..

Operation verification

%%bash
mecab -v
pip show mecab-python3 | grep -e Name -e Version && echo
cabocha -v && echo
pip show cabocha-python | grep -e Name -e Version 

output


mecab of 0.996

Name: mecab-python3
Version: 0.996.5

cabocha of 0.69

Name: cabocha-python
Version: 0.69
import MeCab
tagger = MeCab.Tagger()
print(tagger.parse("The customer next door is a customer who often eats persimmons"))

output


Neighboring noun,General,*,*,*,*,next to,Tonari,Tonari
Particles,Attributive,*,*,*,*,of,No,No
Customer noun,General,*,*,*,*,Customer,Cuck,Cuck
Is a particle,Particle,*,*,*,*,Is,C,Wow
Often adverbs,General,*,*,*,*,Often,Yoku,Yoku
Persimmon noun,General,*,*,*,*,persimmon,Oyster,Oyster
Eating verb,Independence,*,*,Godan / Wa line reminder,Uninflected word,Eat,Ku,Ku
Customer noun,General,*,*,*,*,Customer,Cuck,Cuck
Auxiliary verb,*,*,*,Special,Uninflected word,Is,Da,Da
EOS
import CaboCha
cp = CaboCha.Parser()
print(cp.parseToString("The customer next door is a customer who often eats persimmons"))

output


next to-D        
Customers-------D
Often---D |
persimmon-D |
Eat-D
It's a customer
EOS

Recommended Posts

The strongest way to use MeCab and CaboCha with Google Colab
Use MeCab and neologd with Google Colab
The easiest way to use OpenCV with python
Easy way to scrape with python using Google Colab
Building an environment to use CaboCha with google colaboratory
The most polite way to use the Google Maps SDK for iOS
From Python to using MeCab (and CaboCha)
How to use mecab, neologd-ipadic on colab
Tweet analysis with Python, Mecab and CaboCha
Use TPU and Keras with Google Colaboratory
Use Python and MeCab with Azure Functions
Specify the browser to use with Jupyter Notebook. Especially Mac. (And Vivaldi)
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
Learn with Shogi AI Deep Learning on Mac and Google Colab Use Google Colab
The easiest way to get started with Django
The easiest way to synthesize speech with python
Until you use the Kaggle API with Colab
Specify the Python executable to use with virtualenv
How to use the Google Cloud Translation API
Introduction to Python with Atom (on the way)
How to use Service Account OAuth and API with Google API Client for python
Use mecab with Python3
How to use the grep command and frequent samples
Specify MinGW as the compiler to use with Python
How to use argparse and the difference between optparse
Easy way to analyze AGN time fluctuations with google Colab with RXTE satellite PCA detector
Playing with LEGO and breaking into the 3D industry-The ultimate goal is to use Unity-
Easy to use Nifty Cloud API with botocore and python
[Google Colab] How to interrupt learning and then resume it
Probably the easiest way to create a pdf with Python3
Use MeCab to translate sloppy sentences in a "slow" way.
[Python] I want to use the -h option with argparse
"Deep copy" and "Shallow copy" to understand with the smallest example
The usual way to add a Kernel with Jupyter Notebook
Save images on the web to Drive with Python (Colab)
Deep Learning with Shogi AI on Mac and Google Colab
Upload and delete files to Google Cloud Storages with django-storage
Use MeCab to fetch readings
How to use the generator
About learning with google colab
How to use the decorator
How to use Google Colaboratory
Low Cost RPA with Google APIs and Python -Post Table Data to Slides: Use Case Overview-
[Python] What is pip? Explain the command list and how to use it with actual examples
Use with Cabocha to automatically generate "IOB2 tag corpus" learning data
Repeat with While. Scripts to Tweet and search from the terminal
Deep Learning with Shogi AI on Mac and Google Colab Chapter 11
Save the results of crawling with Scrapy to the Google Data Store
Get the strongest environment with VS Code, Remote-Containers and remote docker-daemon
Deep Learning with Shogi AI on Mac and Google Colab Chapters 1-6
Easy way to round off to the nearest whole number with python3
Deep Learning with Shogi AI on Mac and Google Colab Chapter 8
[September 2020 version] Explains the procedure to use Gmail API with Python
Get conversions and revenue with Google Analytics API and report to Slack
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
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
[Memo] How to use BeautifulSoup4 (2) Display the article headline with Requests