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
160
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
B3 コアタイム 第3回目 ( 2014年11月28日(金) )
MIKAMI-YUKI
November 28, 2014
More Decks by MIKAMI-YUKI
See All by MIKAMI-YUKI
2016年_年次大会_発表資料
mikamiy
0
140
文献紹介_10_意味的類似性と多義解消を用いた文書検索手法
mikamiy
0
360
文献紹介_9_コーパスに基づく動詞の多義解消
mikamiy
0
140
文献紹介_8_単語単位による日本語言語モデルの検討
mikamiy
0
110
文献紹介_7_自動獲得した未知語の読み・文脈情報による仮名漢字変換
mikamiy
0
130
文献紹介_6_複数の言語的特徴を用いた日本語述部の同義判定
mikamiy
0
120
文献紹介_5_マイクロブログにおける感情・コミュニケーション・動作タイプの推定に基づく顔文字の推薦
mikamiy
0
160
文献紹介_4_結合価パターンを用いた仮名漢字変換候補の選択
mikamiy
0
420
文献紹介_3_絵本のテキストを対象とした形態素解析
mikamiy
1
430
Other Decks in Education
See All in Education
AI時代のセキュリティ監査
matshogo
PRO
0
100
AIの力を100%引き出すために
frievea
0
480
[2026前期火5] 論理学(京都大学文学部 前期 第5回)「 ならばの問題演習・proof net・かつの規則」
yatabe
0
420
Lectura 2 (PIT : Python Basico)
robintux
0
430
[2026前期火5] 論理学(京都大学文学部 前期 第9回)「正規化の停止性——ヒドラゲームによる証明」
yatabe
0
260
면접관 눈에 띄는 데이터 분석 포트폴리오 만드는 법 | 2026년 5월 세미나
datarian
0
1.1k
[2026前期火5] 論理学(京都大学文学部 前期 第13回)「走って、止まって、積み上がる」
yatabe
0
210
Geografía y fútbol. Atlanta. la megalópolis del fútbol
juanmartin2026
1
12k
子どものためのプログラミング道場『CoderDojo』〜法人提携例〜 / Partnership with CoderDojo Japan
coderdojojapan
PRO
4
19k
Examen de Selectividad. Geografía julio 2026 (Convocatoria Extraordinaria). UCLM
juanmartin2026
1
13k
生成AI時代のエンジニア育成について考えてみた
akasan
0
230
Claudeに作らせた線形代数講義資料(数回分)
take326
0
110
Featured
See All Featured
Utilizing Notion as your number one productivity tool
mfonobong
4
570
The Pragmatic Product Professional
lauravandoore
37
7.4k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
660
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.7k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
310
Navigating Weather and Climate Data
rabernat
0
510
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
560
Paper Plane
katiecoart
PRO
2
53k
sira's awesome portfolio website redesign presentation
elsirapls
0
400
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) など