Coder Social home page Coder Social logo

comainu's Introduction

Comainu

Comainu is middle-unit-word and long-unit-word analyzer.

Download and Install (Linux)

  1. Download source or git clone
tar -xzf Comainu-0.80-src.tgz
  • git clone
git clone https://github.com/skozawa/Comainu.git Comainu-0.80
  1. Download model file

*The unarchieved model size is about 1.2 GB.

tar -xzf Comainu-0.80-model.tgz
  1. Install

Run either one of the following two ways to configure

  • Configuration including related tools install
    • CRF++, TinySVM, Yamcha, MeCab, unidic-mecab, sqlite3, unidic2, and perl will be installed
    • Note: This script takes about one hour
    • This script require gcc, wget, curl, tar, bzip2, patch, unzip and sed commands
./script/setup.sh
  • only configuration
    • Already installed required tools (CRF++, Yamcha, MeCab, etc.)
./configure

Requirements

  • UNIX:

  • Require for morphological analysis

    • MeCab: mecab-0.98 or later
    • UniDic-MeCab: unidic-mecab-2.1.1 or later
    • Unidic2: unidic-2.1.0 or later
      • SQLite: 3.8 or later
      • perl-DBI, perl-DBD-SQLite
  • Require for middle-word analysis

    • Java runtime: Java 1.6.0 or later
    • MSTParser: MSTParser 0.5.0 or later (bundled)

Usage

Analyze plain text

Comainu analyzes long-unit-word, middle-unit-word and bunsetsu boudnary. (short-unit-word is analyzed by MeCab and UniDic-MeCab)

  • plain2longout
$ echo "固有名詞に関する論文を執筆した" | ./script/comainu.pl plain2longout
B	固有	コユー	コユウ	固有	名詞-普通名詞-形状詞可能			漢	名詞-普通名詞-一般	**	コユウメイシ	固有名詞	固有名詞
	名詞	メーシ	メイシ	名詞	名詞-普通名詞-一般			漢	*	*	*	*	**
	に	ニ	ニ	に	助詞-格助詞			和	助詞-格助詞	*	*	ニカンスル	に関する	に関する
	関する	カンスル	カンスル	関する	動詞-一般	サ行変格	連体形-一般	混	*	**	*	*	*
	論文	ロンブン	ロンブン	論文	名詞-普通名詞-一般			漢	名詞-普通名詞-一般	*	*	ロンブン	論文	論文
	を	オ	ヲ	を	助詞-格助詞			和	助詞-格助詞	*	*	ヲ	を	を
	執筆	シッピツ	シッピツ	執筆	名詞-普通名詞-サ変可能			漢	動詞-一般	サ行変格	連用形-一般	シッピツスル	執筆する	執筆し
	し	シ	スル	為る	動詞-非自立可能	サ行変格	連用形-一般	和	*	*	*	**	*
	た	タ	タ	た	助動詞	助動詞-タ	終止形-一般	和	助動詞	助動詞-タ	終止形-一般	タ	た	た
EOS
  • plain2midout
$ echo "固有名詞に関する論文を執筆した" | ./script/comainu.pl plain2midout
B	固有	コユー	コユウ	固有	名詞-普通名詞-形状詞可能			漢	*	*	コユウメイシ	固有名詞	*	1	0	固有名詞
	名詞	メーシ	メイシ	名詞	名詞-普通名詞-一般			漢	*	*	*	*	**	0
	に	ニ	ニ	に	助詞-格助詞			和	*	*	ニカンスル	に関する	*	3	1	に関する
	関する	カンスル	カンスル	関する	動詞-一般	サ行変格	連体形-一般	混	*	**	*	*	*	1
	論文	ロンブン	ロンブン	論文	名詞-普通名詞-一般			漢	*	*	ロンブン	論文	*	*	2	論文
	を	オ	ヲ	を	助詞-格助詞			和	*	*	ヲ	を	*	*3	を
	執筆	シッピツ	シッピツ	執筆	名詞-普通名詞-サ変可能			漢	サ行変格	連用形-一般	シッピツスル	執筆する	*	7	4	執筆し
	し	シ	スル	為る	動詞-非自立可能	サ行変格	連用形-一般	和	*	*	*	**	*	4
	た	タ	タ	た	助動詞	助動詞-タ	終止形-一般	和	助動詞-タ	終止形-一般	タ	た	*	*	5	た
EOS
  • plain2bnstout
$ echo "固有名詞に関する論文を執筆した" | ./script/comainu.pl plain2bnstout
*B
B	固有	コユー	コユウ	固有	名詞-普通名詞-形状詞可能			漢
	名詞	メーシ	メイシ	名詞	名詞-普通名詞-一般			漢
	に	ニ	ニ	に	助詞-格助詞			和
	関する	カンスル	カンスル	関する	動詞-一般	サ行変格	連体形-一般	混
*B
	論文	ロンブン	ロンブン	論文	名詞-普通名詞-一般			漢
	を	オ	ヲ	を	助詞-格助詞			和
*B
	執筆	シッピツ	シッピツ	執筆	名詞-普通名詞-サ変可能			漢
	し	シ	スル	為る	動詞-非自立可能	サ行変格	連用形-一般	和
	た	タ	タ	た	助動詞	助動詞-タ	終止形-一般	和
EOS
  • plain2longbnstout
$ ./script/comainu.pl plain2longbnstout --input sample/plain/sample.txt --output-dir out
  • plain2midbnstout
$ ./script/comainu.pl plain2midbnstout --input sample/plain/sample.txt --output-dir out

Analyze BCCWJ text

  • bccwj2longout
$ ./script/comainu.pl bccwj2longout --input sample/sample.bccwj.txt
OC01_00001_c    10	30	B	詰め	ツメル	詰める		動詞-一般	下一段-マ行	連用形-一般		ツメ	ツメル	ツメ	ツメル	ツメ	ツメル	詰める	詰め	詰める	和			詰め	10	B	B	詰め将棋	ツメショウギ	詰め将棋	名詞-普通名詞-一般	*	*
OC01_00001_c	30	50		将棋	ショウギ	将棋		名詞-普通名詞-一般				ショーギ	ショーギ	ショウギ	ショウギ	ショウギ	ショウギ	将棋	将棋	将棋	漢			将棋	20		Ia	*	*	*	*	*	*
OC01_00001_c	50	60		の	ノ	の		助詞-格助詞				ノ	ノ	ノ	ノ	ノ	ノ	の	の	の	和			の	30		Ba	の	ノ	の	助詞-格助詞	*	*
OC01_00001_c	60	70		本	ホン	本		名詞-普通名詞-一般				ホン	ホン	ホン	ホン	ホン	ホン	本	本	本	漢			本	40	B	Ba	本	ホン	本	名詞-普通名詞-一般	*	*
OC01_00001_c	70	80		を	ヲ	を		助詞-格助詞				オ	オ	ヲ	ヲ	ヲ	ヲ	を	を	を	和			を	50		Ba	を	ヲ	を	助詞-格助詞	*	*
OC01_00001_c	80	100		買っ	カウ	買う		動詞-一般	五段-ワア行-一般	連用形-促音便		カッ	カウ	カッ	カウ	カッカウ	買う	買っ	買う	和			買っ	60	B	B	買っ	カウ	買う	動詞-一般	五段-ワア行-一般	連用形-促音便
OC01_00001_c	100	110		て	テ	て		助詞-接続助詞				テ	テ	テ	テ	テ	テ	て	て	て	和			て	70		Ba	て	テ	て	助詞-接続助詞	*	*
...
  • bccwj2midout
$ ./script/comainu.pl bccwj2midout --input sample/sample.bccwj.txt --output-dir out
  • bccwj2bnstout
$ ./script/comainu.pl bccwj2bnstout --input sample/sample.bccwj.txt --output-dir out
  • bccwj2longbnstout
$ ./script/comainu.pl bccwj2longbnstout --input sample/sample.bccwj.txt --output-dir out
  • bccwj2midbnstout
$ ./script/comainu.pl bccwj2midbnstout --input sample/sample.bccwj.txt --output-dir out
  • bccwjlong2midout
$ ./script/comainu.pl bccwjlong2midout --input sample/sample.bccwj.txt --output-dir out

Analyze KC text

  • kc2longout
$ ./script/comainu.pl kc2longout --input sample/sample.KC
B 詰め ツメル 詰める 動詞-一般 下一段-マ行 連用形-一般 ツメ ツメル 詰める 詰め * * 和 名詞-普通名詞-一般 * * ツメショウギ 詰め将棋 詰め将棋
Ia 将棋 ショウギ 将棋 名詞-普通名詞-一般 * * ショウギ ショウギ 将棋 将棋 * * 漢 * * * * * *
Ba の ノ の 助詞-格助詞 * * ノ ノ の の * * 和 助詞-格助詞 * * ノ の の
Ba 本 ホン 本 名詞-普通名詞-一般 * * ホン ホン 本 本 * * 漢 名詞-普通名詞-一般 * * ホン 本 本
Ba を ヲ を 助詞-格助詞 * * ヲ ヲ を を * * 和 助詞-格助詞 * * ヲ を を
B 買っ カウ 買う 動詞-一般 五段-ワア行-一般 連用形-促音便 カッ カウ 買う 買っ * * 和 動詞-一般 五段-ワア行-一般 連用形-促音便 カウ 買う 買っ
Ba て テ て 助詞-接続助詞 * * テ テ て て * * 和 助詞-接続助詞 * * テ て て
B き クル 来る 動詞-非自立可能 カ行変格 連用形-一般 キ クル 来る 来 * * 和 動詞-一般 カ行変格 連用形-一般 クル 来る き
Ba まし マス ます 助動詞 助動詞-マス 連用形-一般 マシ マス ます まし * * 和 助動詞 助動詞-マス 連用形-一般 マス ます まし
Ba た タ た 助動詞 助動詞-タ 終止形-一般 タ タ た た * * 和 助動詞 助動詞-タ 終止形-一般 タ た た
Ba 。 * 。 補助記号-句点 * *   。 。 * * 記号 補助記号-句点 * *  。 。
EOS
...
  • kc2bnstout
$ ./script/comainu.pl kc2bnstout --input sample/sample.KC --output-dir out
  • kclong2midout
$ ./script/comainu.pl kclong2midout --input sample/sample_mid.KC --output-dir out

Train model

  • kc2longmodel
$ ./script/comainu.pl kc2longmodel sample/sample.KC sample_train 
  • kclong2midmodel
$ ./script/comainu.pl kclong2midmodel sample/sample_mid.KC sample_train
  • kc2bnstmodel
$ ./script/comainu.pl kc2bnstmodel sample/sample.KC sample_train

Evaluate model

  • kc2longeval
$ ./script/comainu.pl kc2longeval sample/sample.KC out/sample.KC.lout out
  • kclong2mideval
$ ./script/comainu.pl kclong2mideval sample/sample_mid.KC out/sample_mid.KC.mout out
  • kc2bnsteval
$ ./script/comainu.pl kc2bnsteval sample/sample.KC out/sample.KC.bout out

Input/Output format

Under construction

For Developer

Test

  • Add test module
$ ./local/opt/perl-${PERL_VERSION}/bin/cpanm install Test::Mock::Guard Test::Class
  • Test
$ ./local/opt/perl-${PERL_VERSION}/bin/prove t/
  • Run samples
sh t/sample-exec.sh

Packaging

  • upgrade versions
  • configure or setup
  • make destribution for Linux (on Linux)
$ make dist-src
$ make dist-model
  • make destribution for Windows (on Windows)
$ make dist

comainu's People

Contributors

skozawa avatar

Stargazers

Makoto Kadowaki avatar  avatar Masataka Ogawa avatar Kirian Guiller avatar Shinji Kono avatar  avatar IKEGAMI Yukino avatar Paul O'Leary McCann avatar Kozo Chikai avatar Takahashi Kanji avatar takegue avatar Nozomu Kaneko avatar Ahmed Fasih avatar Pulkit Kathuria avatar Hideaki Takahashi avatar mactkg avatar GOTOH, Yutaka avatar Pantelis Koukousoulas avatar Naoya Murakami avatar Philip Quinn avatar Bor Hodošček avatar

Watchers

James Cloos avatar  avatar jacobiz avatar takegue avatar

Forkers

miettal

comainu's Issues

形態素解析の辞書を変更する方法について

研究でComainuを使わせていただいているのですが、形態素解析の辞書について、ご質問したいことがあります。

デフォルトではUniDicが使われると思うのですが、neologdなど、他の辞書を形態素解析の段階で簡単に使う方法がもしあれば、教えていただけますか?

インストールに関して

東方 Fedora24 を利用して Comainu のインストールをしようとしています。
/script/setup.sh を実行しているのですが、YamCha のインストールの際に、エラーを吐きます。

make  all-recursive
make[1]: ディレクトリ '/home/xxx/yamcha-0.33' に入りmます
Making all in src
make[2]: ディレクトリ '/home/xxx/yamcha-0.33/src' に入ります
/bin/sh ../libtool --mode=compile --tag=CXX g++ -DHAVE_CONFIG_H -I. -I. -I..
-O3 -Wno-deprecated -Wall -c -o feature_index.lo feature_index.cpp
 g++ -DHAVE_CONFIG_H -I. -I. -I.. -O3 -Wno-deprecated -Wall -c feature_index.cpp
-fPIC -DPIC -o .libs/feature_index.o
feature_index.cpp: In member function 'bool
YamCha::FeatureIndex::setFeature(const string&, int)':
feature_index.cpp:150:62: error: no matching function for call to
'make_pair(const int&, const int&)'
    feature_set.insert (std::make_pair <int, int>( *rit, *cit ) );
                                                              ^
In file included from /usr/include/c++/6.2.1/utility:70:0,
                 from /usr/include/c++/6.2.1/tuple:38,
                 from /usr/include/c++/6.2.1/functional:55,
                 from feature_index.cpp:23:
/usr/include/c++/6.2.1/bits/stl_pair.h:425:5: note: candidate: template<class
_T1, class _T2> constexpr std::pair<typename
std::__decay_and_strip<_Tp>::__type, typename
std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&)
     make_pair(_T1&& __x, _T2&& __y)
     ^~~~~~~~~
/usr/include/c++/6.2.1/bits/stl_pair.h:425:5: note:   template argument
deduction/substitution failed:
feature_index.cpp:150:51: note:   cannot convert
'rit.std::_Rb_tree_const_iterator<_Tp>::operator*<int>()' (type 'const int') to
type 'int&&'
    feature_set.insert (std::make_pair <int, int>( *rit, *cit ) );
                                                   ^~~~
feature_index.cpp:154:66: error: no matching function for call to
'make_pair(const int&, const int&)'
    bow_feature_set.insert (std::make_pair <int, int>( *rit, *cit ) );
                                                                  ^
In file included from /usr/include/c++/6.2.1/utility:70:0,
                 from /usr/include/c++/6.2.1/tuple:38,
                 from /usr/include/c++/6.2.1/functional:55,
                 from feature_index.cpp:23:
/usr/include/c++/6.2.1/bits/stl_pair.h:425:5: note: candidate: template<class
_T1, class _T2> constexpr std::pair<typename
std::__decay_and_strip<_Tp>::__type, typename
std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&)
     make_pair(_T1&& __x, _T2&& __y)
     ^~~~~~~~~
/usr/include/c++/6.2.1/bits/stl_pair.h:425:5: note:   template argument
deduction/substitution failed:
feature_index.cpp:154:55: note:   cannot convert
'rit.std::_Rb_tree_const_iterator<_Tp>::operator*<int>()' (type 'const int') to
type 'int&&'
    bow_feature_set.insert (std::make_pair <int, int>( *rit, *cit ) );
                                                       ^~~~
Makefile:335: ターゲット 'feature_index.lo' のレシピで失敗しました
make[2]: *** [feature_index.lo] エラー 1
make[2]: ディレクトリ '/home/xxx/yamcha-0.33/src' から出ます
Makefile:302: ターゲット 'all-recursive' のレシピで失敗しました
make[1]: *** [all-recursive] エラー 1
make[1]: ディレクトリ '/home/xxx/yamcha-0.33' から出ます
Makefile:200: ターゲット 'all' のレシピで失敗しました
make: *** [all] エラー 2

これは何を修正すればよいのでしょうか?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.