Tree taggerの導入を行おうと思って色々調べたが、少し詰まったのでメモ
Download項目の
- Download the tagger package for your system (PC-Linux, Mac OS-X (Intel-CPU), PC-Linux (version for older kernels)).
- Download the tagging scripts into the same directory.
- Download the installation script install-tagger.sh.
- Download the parameter files for the languages you want to process.
- Open a terminal window and run the installation script in the directory where you have downloaded the files:sh install-tagger.sh
- Make a test, e.g. echo 'Hello world!' | cmd/tree-tagger-english or echo 'Das ist ein Test.' | cmd/tagger-chunker-german
以上を参考に、上記4ファイルをダウンロード(解凍は不必要)
Macでターミナルを起動し、以下を実行
> cd
> mkdir tree_tagger
> open .
ダウンロードした4項目を、tree_taggerフォルダに移動、その後、以下のコマンドを実行
> sh install-tagger.sh
最初はめんどくさがってDownloadフォルダ内で行っていたらうまく動作しなかったが、Home直下で実行したら動いた。
> echo 'Hello world!' | cmd/tree-tagger-english
reading parameters ...
tagging ...
finished.
Hello UH Hello
world NN world
環境変数は特にいじらなくても問題無し(自分の場合は)
:追記(20161124)
Tree taggerをPythonに導入したので追記。
pip3 install treetaggerwrapper
自分は3系に入れたかったので、pip→pip3
Pythonコード内で
import treetaggerwrapper as ttw
tagger = ttw.TreeTagger(TAGLANG='en')
tags = tagger.TagText('hello world')
で動作。
自分は指定しなかったが、動作しない場合はTAGDIR=
に導入ディレクトリを指定すればいいみたい。
import treetaggerwrapper as ttw
tagger = ttw.TreeTagger(TAGLANG='en',TAGDIR='…/hogehoge')
tags = tagger.TagText('hello world')
参考:
http://otani0083.hatenablog.com/entry/2013/10/01/195037
http://treetaggerwrapper.readthedocs.io/en/latest/