LoginSignup
0
0

More than 5 years have passed since last update.

Tree tagger 導入メモ

Last updated at Posted at 2016-11-23

Tree taggerの導入を行おうと思って色々調べたが、少し詰まったのでメモ

Download項目の

  1. Download the tagger package for your system (PC-Linux, Mac OS-X (Intel-CPU), PC-Linux (version for older kernels)).
  2. Download the tagging scripts into the same directory.
  3. Download the installation script install-tagger.sh.
  4. Download the parameter files for the languages you want to process.
  5. Open a terminal window and run the installation script in the directory where you have downloaded the files:sh install-tagger.sh
  6. 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/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0