DEV Community

Toru Furukawa
Toru Furukawa

Posted on

3 2

入門自然言語処理 pp.199-203

5.2 はタグ付きコーパスの続き。

タグの NN$ のように、$がついているとプロットするときのラベルとしてパースでいないので、雑に削除するコードを昨日書いた。んだけど、これはよくないことに気づく。

読み進めていくと、NN タグは spam のような一般的な名詞、 NN$ タグは spam's のような所有格名詞を表す。

import nltk
tagged_words = nltk.corpus.brown.tagged_words(categories="news")
dist = nltk.FreqDist(tag.replace("$", r"\$") for (word, tag) in tagged_words)
dist.plot()
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay