DEV Community

Toru Furukawa
Toru Furukawa

Posted on

3 3

入門自然言語処理 pp.86-117

3.2章は、Python の基本的な文字列処理。3.3 は Unicode とエンコーディングの考え方。Python 2 を前提にしているので、 u"..." とか。3.4、3.5 は正規表現と nltk の検索関数。

import nltk
from nltk.corpus import gutenberg, nps_chat

moby = nltk.Text(gutenberg.words("melville-moby_dick.txt"))
moby.findall(r"<a> (<.*>) <man>")

chat = nltk.Text(nps_chat.words())
chat.findall(r"<.*> <.*> <bro>")
chat.findall(r"<l.*>{3,}")
Enter fullscreen mode Exit fullscreen mode

3.6 は正規化、ステミング。

Top comments (0)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

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

Okay