Corpus with Tags (12.1.2)

Import ChaSen:

>>> from chasen import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named chasen
>>> from nltk.corpus.reader.chasen import *

According to the textbook, the corpus was already download at set up (nltk.download() -> Select package named 'all'). However, I got an error message just typing "from chasen import *". Need to specify the full name (nltk.corpus.reader.chasen).

>>> jeita = ChasenCorpusReader('/Users/xxx/nltk_data/corpora', '.*chasen', endcoding='utf-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'endcoding'
>>> jeita = ChasenCorpusReader('/Users/xxx/nltk_data/corpora', '.*chasen', 'utf-8')
>>> print '/'.join(jeita.words()[22100:22140])
たい/という/気持/が/、/この上なく/純粋/に/、/この上なく/強烈/で/あれ/ば/、/ついに/は/そのもの/に/なれる/。/なれ/ない/の/は/、/まだ/その/気持/が/そこ/まで/至っ/て/い/ない/から/だ/。/法

This part is also different from the text book. In the text, parameter for encoding was "encoding='utf-8'" but I got an error message. Then I just put 'utf-8' as the parameter, it worked.

>>> print '\nEOS\n'.join(['\n'.join("%s/%s" % (w[0],w[1].split('\t')[2]) for w
...      in sent) for sent in jeita.tagged_sents()[2170:2173]])
を/助詞-格助詞-一般
まくっ/動詞-自立
た/助動詞
とき/名詞-非自立-副詞可能
吹き/動詞-自立
こむ/動詞-非自立
粉雪/名詞-一般
の/助詞-連体化
ため/名詞-非自立-副詞可能
に/助詞-格助詞-一般
、/記号-読点
彼/名詞-代名詞-一般
の/助詞-連体化
姿/名詞-一般
は/助詞-係助詞
瞬間/名詞-副詞可能
に/助詞-格助詞-一般
みえ/動詞-自立
なく/助動詞
なっ/動詞-自立
た/助動詞
。/記号-句点
それなり/名詞-一般
だ/助動詞
。/記号-句点
橇/名詞-固有名詞-地域-一般
犬/名詞-一般
の/助詞-連体化
声/名詞-一般
が/助詞-格助詞-一般
やがて/副詞-一般
外/名詞-一般
でし/助動詞
た/助動詞
。/記号-句点
岩/名詞-一般
が/助詞-格助詞-一般
ちぎっ/動詞-自立
て/助詞-接続助詞
くる/動詞-非自立
よう/名詞-非自立-助動詞語幹
な/助動詞
吹雪/名詞-一般
の/助詞-連体化
合間/名詞-一般
合間/名詞-一般
に/助詞-格助詞-一般
、/記号-読点
しだいに/副詞-一般
遠ざかっ/動詞-自立
て/助詞-接続助詞
ゆく/動詞-非自立
鈴/名詞-一般
の/助詞-連体化
音/名詞-一般
、/記号-読点
犬/名詞-一般
の/助詞-連体化
声/名詞-一般
。/記号-句点
EOS
 /記号-空白
行っ/動詞-自立
て/助詞-接続助詞
しまっ/動詞-非自立
た/助動詞
。/記号-句点
極北/名詞-固有名詞-地域-一般
の/助詞-連体化
神秘/名詞-一般
「/記号-括弧開
EOS
冥/名詞-サ変接続
路/名詞-接尾-一般
の/助詞-連体化
国/名詞-一般
>>> 

This did not work at first. The reason was the code in my "paper" textbook was like following.

>>> print '\nEOS\n'.join(['\n'.join("%s/%s" % (w[0],w[1][2]) for w in sent) for sent in jeita.tagged_sents()[2170:2173]])

If you will start to learn or are learning now, you should refer to http://nltk.googlecode.com/svn/trunk/doc/book-jp/ch12.html instead of the paper version of the textbook!!!!