Last active
January 3, 2018 21:58
-
-
Save yoshiiz/5546a9d180e020cbf1e5f3f245c315fb to your computer and use it in GitHub Desktop.
[Python 3] TreeTagger を Windows+Python 3 環境で利用するサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import treetaggerwrapper as ttw | |
# 解析対象の英文 | |
text = 'Peter piper picked a peck of pickled peppers.' | |
# word, pos, lemma からなるタブ区切りの文字列のリストを取得する。 | |
tags_tabseparated = ttw.TreeTagger(TAGLANG='en').tag_text(text) | |
# word, pos, lemma からなるタプルのリストを作成する。 | |
tags_tuple = ttw.make_tags(tags_tabseparated) | |
# word, pos, lemma の一覧を表示する。 | |
for tag in tags_tuple: | |
print("{0}\t{1}\t{2}".format(tag[0], tag[1], tag[2])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment