[Environment construction] Dependency analysis using CaboCha in Python 2.7

For Ubuntu 14.04, write a memo about the environment construction to enable CaboCha, which performs Japanese natural sentence dependency analysis, to be used from Python 2.7.

First, MeCab, which performs morphological analysis under CaboCha, is required first. On Ubuntu 14.04 you can install MeCab 0.996 with apt-get.

$ sudo apt-get install build-essential mecab libmecab-dev mecab-ipadic mecab-ipadic-utf8 python-mecab
$ mecab --version
mecab of 0.996
$ mecab-config --version
0.996
$ mecab
Of the thighs and thighs
Plum noun,General,*,*,*,*,Plum,Plum,Plum
Also particles,Particle,*,*,*,*,Also,Mo,Mo
Peach noun,General,*,*,*,*,Peaches,peach,peach
Also particles,Particle,*,*,*,*,Also,Mo,Mo
Peach noun,General,*,*,*,*,Peaches,peach,peach
Particles,Attributive,*,*,*,*,of,No,No
Noun,Non-independent,Adverbs possible,*,*,*,home,Uchi,Uchi
EOS

Then build CRF ++-0.58.tar.gz. CRF ++ must be installed first as the CaboCha library seems to refer to it. Is MeCab using the * conditional random field * (CRF) internally using the crf_learn command, or is it necessary to have a header or lib for compilation?

$ tar zxvf CRF++-0.58.tar.gz
$ cd CRF++-0.58/
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig

Download cabocha-0.69.tar.gz from the official website and build CaboCha 0.69 + cabocha-python.

$ tar zxvf cabocha-0.69.tar.gz
$ cd cabocha-0.69
$ ./configure --with-mecab-config=`which mecab-config` --with-charset=UTF8
$ make
$ sudo make install
$ cabocha --version
cabocha of 0.69
$ cabocha
Of the thighs and thighs
Thigh-D
Peach---D
Thigh-D
home
EOS
$ cd python
$ python setup.py install  #sudo/May enter usr
$ python -c "import CaboCha; p=CaboCha.Parser(); print(p.parseToString('Of the thighs and thighs'))"
Thigh-D
Peach---D
Thigh-D
home
EOS

Note that setup.py does not support Python 3 syntax constraints, so if you can say it to Python 3, you need to fix it (search for it).

that's all.

Recommended Posts

[Environment construction] Dependency analysis using CaboCha in Python 2.7
Python3.6 environment construction (using Win environment Anaconda)
Python environment construction
Environment construction (python)
python environment construction
Python --Environment construction
Python environment construction
python environment construction
Using venv in Windows + Docker environment [Python]
python windows environment construction
Data analysis using Python 0
homebrew python environment construction
Dependency analysis with CaboCha
Python development environment construction
Perform entity analysis using spaCy / GiNZA in Python
virtual environment in python
python2.7 development environment construction
Association analysis in Python
Development environment in Python
Mac environment construction Python
Python environment construction @ Win7
Regression analysis in Python
Data analysis environment construction with Python (IPython notebook + Pandas)
OpenVINO using Inference Engine Python API in PC environment
Python + Anaconda + Pycharm environment construction
CI environment construction ~ Python edition ~
Handle environment variables in Python
Anaconda3 python environment construction procedure
Axisymmetric stress analysis in Python
Python3 environment construction (for beginners)
Python environment construction and TensorFlow
Python environment construction under Windows7 environment
Simple regression analysis in Python
[MEMO] [Development environment construction] Python
Environment construction of python2 & 3 (OSX)
Data analysis using python pandas
Translate using googletrans in Python
Using Python mode in Processing
DI (Dependency Injection) in Python
[Introduction] Artificial satellite data analysis using Python (Google Colab environment)
Python environment construction procedure memo using Docker on Windows10 Home
Install CaboCha in Ubuntu environment and call it with Python.
Morphological analysis using Igo + mecab-ipadic-neologd in Python (with Ruby bonus)
VScode environment construction (on Mac) & graph display in Python (@browser)
EEG analysis in Python: Python MNE tutorial
Environment construction of python and opencv
GUI programming in Python using Appjar
Python environment construction memo on Windows 10
Get started with Python! ~ ① Environment construction ~
Precautions when using pit in Python
First simple regression analysis in Python
Anaconda python environment construction on Windows 10
Python + Unity Reinforcement learning environment construction
Install scrapy in python anaconda environment
I checked Mac Python environment construction
Python environment construction memo on Mac
Python environment construction (pyenv, anaconda, tensorflow)
[Python3] Development environment construction << Windows edition >>
install tensorflow in anaconda + python3.5 environment
Python development environment construction on macOS
Python environment construction (pyenv + poetry + pipx)