[RUBY] Cabocha installation notes

Now that Mecab is installed, install Cabocha 0.67 and call it from Ruby and Python.

Install Cabocha Install CRF ++ before installing Cabocha, and then install Cabocha.
$ wget http://crfpp.googlecode.com/files/CRF%2B%2B-0.58.tar.gz
$ tar zvxf  CRF++-0.58.tar.gz
$ cd CRF++-0.58
$ ./configure
$ make 
$ sudo make install
$ ls /usr/local/lib
$ sudo ldconfig
$ cd ~
$
$ wget http://cabocha.googlecode.com/files/cabocha-0.67.tar.bz2
$ tar xjvf cabocha-0.67.tar.bz
$ cd cabocha-0.67
$ ./configure --with-charset=UTF8 --with-posset=IPA
$ make
$ sudo make install
$ sudo ldconfig
$ cabocha

Cabocha test Start Cabocha and try to analyze the dependency.
$ cabocha
The customer next door is a customer who often eats persimmons
next to-D
Customers-----D
Often---D
persimmon-D
It's a customer who eats
EOS

Ruby binding Allows you to call Cabocha from Ruby.
$ cd ruby
$ /opt/ruby/current/bin/ruby extconf.rb
$ make
$ sudo make install

Test from Ruby As with Mecab, a test file is prepared, so run it as it is.
$ /opt/ruby/current/bin/ruby test.rb

Python binding Make it callable from Python as well. Edit as you would in Mecab, then run the setup script.
$ sudo vi setup.py
	return cmd1(str).split() ←def cmd2(str):Change the contents(1 place)
	/usr/local/bin/cabocha-config ←cabocha-Change config(4 places)
$ sudo /opt/python/current/bin/python setup.py build_ext
$ sudo /opt/python/current/bin/python setup.py install
$ sudo ldconfig

Test from Python As with Mecab, the test script file will result in an error in Python3 series, but since it is easy to fix, edit the script file itself.
$ cd ../python/
$ sudo vi test.py
	print(c.parseToString(sentence))← print()Come out
	print(tree.toString(CaboCha.FORMAT_TREE))← Same()Come out
	print(tree.toString(CaboCha.FORMAT_LATTICE))← Similar
$ /opt/python/current/bin/python test.py
Taro-----------D
this-D       |
Book---D   |
Jiro-D   |
saw-D |
To women-D
I handed it over.
EOS

Taro-----------D
this-D       |
Book---D   |
Jiro-D   |
saw-D |
To women-D
I handed it over.
EOS

* 0 6D 0/1 -2.457381
Taro noun,Proper noun,Personal name,Name,*,*,Taro,Taro,Taro
Is a particle,Particle,*,*,*,*,Is,C,Wow
* 1 2D 0/0 1.509507
This adnominal adjective,*,*,*,*,*,this,this,this
* 2 4D 0/1 0.091699
Book noun,General,*,*,*,*,Book,Hong,Hong
Particles,Case particles,General,*,*,*,To,Wo,Wo
* 3 4D 1/2 2.359707
Two nouns,number,*,*,*,*,two,D,D
Ro noun,General,*,*,*,*,Ro,Rowe,Low
Particles,Case particles,General,*,*,*,To,Wo,Wo
* 4 5D 0/1 1.416783
Verb,Independence,*,*,One step,Continuous form,to see,Mi,Mi
Auxiliary verb,*,*,*,Special,Uninflected word,Ta,Ta,Ta
* 5 6D 0/1 -2.457381
Feminine noun,General,*,*,*,*,Female,Josei,Josei
Particles,Case particles,General,*,*,*,To,D,D
* 6 -1D 0/1 0.000000
Passing verb,Independence,*,*,Godan / Sa line,Continuous form,hand over,I,I
Auxiliary verb,*,*,*,Special,Uninflected word,Ta,Ta,Ta
.. symbol,Kuten,*,*,*,*,。,。,。
EOS

Finished.

Recommended Posts

Cabocha installation notes
Mecab installation notes
pyenv installation notes
Hydrogen installation notes
Python3.4 installation notes
Arch Linux installation notes
Installation notes for TensorFlow for Windows
Homebrew and Pycharm installation instructions notes
JetBrains_Learning Notes_003
Django installation
Cuda installation
SQLAlchemy notes
Pythia Installation
pyenv notes
Volatility installation
Python installation
pip installation
SQL notes
Sphinx installation
Pandas notes
Sphinx notes
django notes
Jupyter_Learning Notes_000
InstantOS 1 installation
Jupyter installation
Python installation
Kivy installation
Backtrader installation
GPD P2 Max Ubuntu Mate installation notes
pip installation
Django notes