Google in English

Googleで検索したときに,英語の結果だけを表示したい時がある.
検索オプションを開いて,対象言語を英語に設定すればいいんだけど,毎回設定するのはめんどくさい.
そんな人におすすめのBookmarklet(前にどっかで拾ってきた)

javascript:var r=RegExp,l=location;if(l.href.match(new r(%22(http://[^/]+\\.google\\.[^/]+/search)(\\?.+)%22))){var u=r.$1,p=r.$2,q=(p.match(/[&\?]q=([^&]*)/))[1];if(q){if(p.match(/[&\?]hl=([^&]*)/))var hl=r.$1;var nhl=(hl==%22ja%22?%22en%22:%22ja%22);l.href=u+%22?q=%22+q+%22&hl=%22+nhl+%22&lr=%22+{%22en%22:%22%22,%22ja%22:%22lang_ja%22}[nhl];}}

macにYamChaをインストール

YamChaが必要になったので,今からインストールする.

YamChaとは...

YamCha is a generic, customizable, and open source text chunker oriented toward a lot of NLP tasks, such as POS tagging, Named Entity Recognition, base NP chunking, and Text Chunking. YamCha is using a state-of-the-art machine learning algorithm called Support Vector Machines (SVMs), first introduced by Vapnik in 1995.

TinySVMのインストール

YamChaには,TinySVMというものが必要らしい.
ソースを拾ってきて,configureの後,makeしてみる...が,エラー.

c++ -DHAVE_CONFIG_H -I. -I. -I.. -Wall -O9 -funroll-all-loops -finline -ffast-math -mieee-fp -c param.cpp -fno-common -DPIC -o .libs/param.lo
./getopt.h:131: error: declaration of C function 'int getopt()' conflicts with
/usr/include/unistd.h:454: error: previous declaration 'int getopt(int, char* const*, const char*)' here

ググってみると,./src/getopt.hの131行目を以下のように修正しないといけないらしい.

/* extern int getopt (); */ /* こちらが元の */
extern int getopt (int argc, char *const *argv, const char *shortopts);

それと,./libtoolのL184の\$CCをg++に変更.
そしたら,問題なくインストールできましたとさ.

YamChaのインストール

さて,次は本題のYamCha.
./configureをすると,以下のエラーが出た.

configure: error: svm_learn (TinySVM or SVM^light) required for training

TinySVMの場所が分からなかったらしい.
後は,下のコマンドを順に実行したらすんなりといけた.

./configure --with-svm-learn=/usr/local/bin
make
sudo make install