Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
B3 コアタイム 第3回目 ( 2014年11月28日(金) )
Search
MIKAMI-YUKI
November 28, 2014
Education
0
160
B3 コアタイム 第3回目 ( 2014年11月28日(金) )
MIKAMI-YUKI
November 28, 2014
Tweet
Share
More Decks by MIKAMI-YUKI
See All by MIKAMI-YUKI
2016年_年次大会_発表資料
mikamiy
0
130
文献紹介_10_意味的類似性と多義解消を用いた文書検索手法
mikamiy
0
310
文献紹介_9_コーパスに基づく動詞の多義解消
mikamiy
0
120
文献紹介_8_単語単位による日本語言語モデルの検討
mikamiy
0
88
文献紹介_7_自動獲得した未知語の読み・文脈情報による仮名漢字変換
mikamiy
0
96
文献紹介_6_複数の言語的特徴を用いた日本語述部の同義判定
mikamiy
0
100
文献紹介_5_マイクロブログにおける感情・コミュニケーション・動作タイプの推定に基づく顔文字の推薦
mikamiy
0
130
文献紹介_4_結合価パターンを用いた仮名漢字変換候補の選択
mikamiy
0
400
文献紹介_3_絵本のテキストを対象とした形態素解析
mikamiy
1
420
Other Decks in Education
See All in Education
演習問題
takenawa
0
5.8k
教員向け生成AI基礎講座(2025年3月28日 東京大学メタバース工学部 ジュニア講座)
luiyoshida
1
570
社外コミュニティと「学び」を考える
alchemy1115
2
170
Interaction - Lecture 10 - Information Visualisation (4019538FNR)
signer
PRO
0
2k
Constructing a Custom TeX Ecosystem for Educational Institutions—Beyond Academic Typesetting
doratex
1
9.6k
Sponsor the Conference | VizChitra 2025
vizchitra
0
550
OpenSourceSummitJapanを運営してみた話
kujiraitakahiro
0
710
モンテカルロ法(3) 発展的アルゴリズム / Simulation 04
kaityo256
PRO
7
1.3k
America and the World
oripsolob
0
510
OJTに夢を見すぎていませんか? ロールプレイ研修の試行錯誤/tryanderror-in-roleplaying-training
takipone
1
150
推しのコミュニティはなんぼあってもいい / Let's join a lot of communities.
kaga
2
1.7k
Dashboards - Lecture 11 - Information Visualisation (4019538FNR)
signer
PRO
1
2k
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
Testing 201, or: Great Expectations
jmmastey
42
7.6k
Documentation Writing (for coders)
carmenintech
72
4.9k
It's Worth the Effort
3n
185
28k
4 Signs Your Business is Dying
shpigford
184
22k
We Have a Design System, Now What?
morganepeng
53
7.7k
Practical Orchestrator
shlominoach
188
11k
Agile that works and the tools we love
rasmusluckow
329
21k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
Rebuilding a faster, lazier Slack
samanthasiow
82
9.1k
Unsuck your backbone
ammeep
671
58k
Transcript
「入門 自然言語処理」 2章:テキストコーパスと語彙資源へのアクセス B3 三上侑城
もくじ •テキストコーパスへのアクセス •条件付き頻度分布 •語彙資源 •WordNet
テキストコーパスへのアクセス •テキストコーパスとは? →様々なテキストが入っている テキスト集 →本、チャットの会話、台本、 レビューなどがある ※研究でコーパスを用いる際には、その サイズと種類(どのぐらいの文量でどの ような話か)を明示する。
テキストコーパスへのアクセス ・入っている電子書籍を見てみる >>>import nltk >>> nltk.corpus.gutenberg.fileids() ※ファイルは以下のディレクトリにある /home/UserName/nltk_data/corpora/gutenberg
テキストコーパスへのアクセス ・電子書籍を読み出す >>>emma = nltk.corpus.gutenberg.words('austen-emma.txt') ・単語数を調べる >>>len(emma)
テキストコーパスへのアクセス ・前回のtext読み出し&検索 >>>from nltk.book import * >>>text1.concordance("test") ・今回のtext読み出し&検索 >>>emma =
nltk.Text(nltk.corpus.gutenberg.words (‘austen-emma.txt’)) >>>emma.concordance('surprize')
テキストコーパスへのアクセス しかし、こんなに長い名前を毎回タイプするの は面倒くさいし大変….. もっと短く書く方法がある >>>from nltk.corpus import gutenberg >>>gutenberg.fileids() #テキスト一覧表示
>>>emma = gutenberg.words('austen-emma.txt')
テキストコーパスへのアクセス ・Webテキストを読み出す >>>from nltk.corpus import webtext >>>for fileid in webtext.fileids
(): ... print fileid, webtext.raw(fileid)[:65], ’...’ ... ・チャットを読み出す 上記の”webtext”全てを”nps_chat”に変更
テキストコーパスへのアクセス ・ブラウンコーパス 一番古い電子コーパスで様々なジャンルの ものが入っている(教科書P45の表2-1参照) >>>from nltk.corpus import brown >>>brown.categories() >>>brown.words(categories='news')
>>>brown.words(fileids=['ca16']) ※例 ID:A16 , ファイル:ca16 , ジャンル:ニュース
テキストコーパスへのアクセス ・ロイターコーパス ニュース関連の文章が収録 >>>from nltk.corpus import reuters >>>reuters.fileids() >>>reuters.categories()
テキストコーパスへのアクセス ・就任演説コーパス 大統領の就任演説が収録 >>> from nltk.corpus import inaugural >>>inaugural.fileids() ※ここでは先頭4文字が年号なことを利用し、年号
の情報のみを受け取ってみる。 >>>[fileid[:4] for fileid in inaugural.fileids()]
テキストコーパスへのアクセス ・他の言語のコーパス 他の言語を使用するには文字コーディング が必要となる。第3章でその説明がある。 ・独自コーパス 自分自身が用意したコーパスも使用可能。 方法は教科書P53-54を参考。
条件付き頻度分布 ・条件と事象をペアにして処理を行う。 形式:(条件(ジャンル) , 事象(単語)) >>>from nltk.corpus import brown >>>genre_word
= [(genre,word) ... for genre in ['news','romance'] ... for word in brown.words(categories=genre)] >>>len(genre_word)
条件付き頻度分布 ・ペアになっていること確認 >>>genre_word[:4] #最初の4つのペア >>>genre_word[-4:] #最後の4つのペア
条件付き頻度分布 ・ジャンルごとに単語を調べる ConditionalFreqDist:ペアから度数分布を生成する >>>cfd = nltk.ConditionalFreqDist(genre_word) >>>cfd >>>cfd.conditions() #条件リスト >>>cfd[‘news’]
#newsの条件での分布 >>>cfd['romance'] >>>list(cfd['romance']) ※教科書P59表2-4に各詳細説目あり
語彙資源 ・語彙リストコーパス 一般的に使われる語彙を集めたコーパス スペルミスや一般的でない単語を発見 することによく使用される。
語彙資源 ・テキストのフィルタリング 関数の作成 >>>def unusual_words(text): ... text_vocab = set(w.lower() for
w in text if w.isalpha()) ... english_vocab = set(w.lower() for w in nltk.corpus.words.words()) ... unusual = text_vocab.difference(english_vocab) ... return sorted(unusual) ※x.lower():小文字にする , x.isalpha():アルファベットか判断 x.difference():差分のみを取り出す
語彙資源 ・テキストのフィルタリング 例として以下のテキストを使用する 主に一般的ではないワードを探す >>>unusual_words(nltk.corpus.gutenberg.words ('austen-sense.txt')) 主にネット上で使われるワードを探す >>>unusual_words(nltk.corpus.nps_chat.words())
語彙資源 ・テキストのフィルタリング the , to , alsoなど頻度が高い単語の コーパスもある(ストップワード) >>>from nltk.corpus
import stopwords >>>stopwords.words('english')
WordNet ・WordNetとは 意味により整列された辞書 例 「motorcar」 , 「automobile」は意味が同じ。 つまりこれらは同義語である。
WordNet ・本当に同義語か確かめてみる >>>from nltk.corpus import wordnet as wn >>>wn.synsets('motorcar') ※「motorcar」がどこに属しているか示される
>>>wn.synset('car.n.01').lemma_names() ※ここに属しているものが見える >>>wn.synset('car.n.01').definition() >>>wn.synset('car.n.01').examples()
WordNet ・WordNetの階層構造 WordNetは概念として、階層構造を 想像できる。 ※概念図は教科書P73図2-8を参照
今回の最低限理解して欲しい事 • テキストコーパス = 構造化されたテキスト集 • 各ジャンルやトピックに別れて用意してある • 関数(メソッド)は 『オブジェクト名.メソッド名(送り値)』
で呼び出すことができる 例:word.isalpha() , x.funct(y) など