Now that Mecab is installed, install Cabocha 0.67 and call it from Ruby and Python.
$ 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
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
$ cd ruby
$ /opt/ruby/current/bin/ruby extconf.rb
$ make
$ sudo make install
$ /opt/ruby/current/bin/ruby test.rb
$ 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
$ 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