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
文字列照合に基づく全文検索について
Search
masaya82
January 23, 2018
0
170
文字列照合に基づく全文検索について
masaya82
January 23, 2018
Tweet
Share
More Decks by masaya82
See All by masaya82
文献紹介 : More is not always better: balancing sense distributions for all-words
masaya82
0
97
文献紹介:Enhancing Modern Supervised Word Sense Disambiguation Models
masaya82
0
110
文献紹介:The Word Sense Disambiguation Test Suite at WMT18
masaya82
0
59
文献紹介:Preposition Sense Disambiguation and Representation
masaya82
0
90
文献紹介:Word Sense Disambiguation Based on Word Similarity Calculation Using Word Vector Representation from a Knowledge-based Graph
masaya82
0
110
Distributional Lesk: Effective Knowledge-Based Word Sense Disambiguation
masaya82
0
74
Japanese all-words WSD system using the Kyoto Text Analysis ToolKit
masaya82
0
73
Improving Word Sense Disambiguation in Neural Machine Translation with Sense Embeddings
masaya82
0
81
Learning_to_Identify_the_Best_Contexts_for_Knowledge-based_WSD
masaya82
0
87
Featured
See All Featured
Building Applications with DynamoDB
mza
88
5.6k
Become a Pro
speakerdeck
PRO
10
4.5k
Build The Right Thing And Hit Your Dates
maggiecrowley
23
2k
Imperfection Machines: The Place of Print at Facebook
scottboms
259
12k
Designing the Hi-DPI Web
ddemaree
276
33k
The Cult of Friendly URLs
andyhume
74
5.7k
Typedesign – Prime Four
hannesfritz
36
2.1k
Music & Morning Musume
bryan
41
5.6k
[RailsConf 2023] Rails as a piece of cake
palkan
22
3.9k
Debugging Ruby Performance
tmm1
70
11k
Reflections from 52 weeks, 52 projects
jeffersonlam
344
19k
Visualization
eitanlees
135
14k
Transcript
文字列照合に基づく 全文検索について 自然言語処理研究室 B3 福嶋 真也
参考文献 北 研二、津田 和彦、獅々堀 正幹 著 「情報検索アルゴリズム」 2002年 共立出版株式会社 平田
富夫 著 「アルゴリズムとデータ構造」 1990年 森北出版会社
全文検索とは 与えられたキーワードに対して、文書中からキーワードと完全 に一致する部分を探し出す技術 テキストエディタの検索コマンドやテキストデータベースの検索、 スペリング検査、テキスト編集などに利用 大きく分けて2つの方法が存在 ・文字列照合を用いる方法 ・索引を用いる方法 今回は文字列照合を用いる方法について紹介
文字列照合に用いられるアルゴリズム 単一のキーワードに対して用いられるアルゴリズム ・ Knuth-Morris-Pratt法(KMP法) ・Boyer-Moore法(BM法) 複数のキーワードに対して用いられるアルゴリズム ・Aho-Corasick法(AC法)
SimpleSearch もっとも単純な文字列照合アルゴリズム キーワード(長さn)に対して検索対象となる文字列(テキストス トリング)の1文字目からn文字目まで一致しているか確認 2文字目からn+1文字まで一致しているか確認 テキストストリングの文字列の末尾まで繰り返す ・ ・ ・
SimpleSearch 例 キーワード abcaba テキストストリング abcabcababcab 位置 1 2 3
4 5 6 7 8 9 10 11 12 13 text a b c a b c a b a b c a b 照合 状況 〇 〇 〇 〇 〇 × × × 〇 〇 〇 〇 〇 ◎ × × 〇 〇 × ×
KMP法 SimpleSearchでは1文字ずつずらす ずらす量を変えることができれば試行回数は少なくなる 失敗関数を用いてずらす量を計算 失敗関数 f(i)=1+max{u|0≦u<i-1,1 2 … = −
−+1 … −1}
KMP法 例 キーワード abcaba テキストストリング abcabcaba 位置 1 2 3
4 5 6 7 8 9 text a b c a b c a b a 照合状況 〇 〇 〇 〇 〇 × 〇 〇 〇 ◎
KMP法 失敗関数 位置 1 2 3 4 5 6 7
キー ワード a b c a b a a b c a b a a b c a b a f(i) 0 1 1 0 1 3 2
BM法 キーワードの末尾から照合をしていくことでずらせる量を増やす 方法 例 キーワード abcaba テキストストリング abcabcaba 位置 1
2 3 4 5 6 7 8 9 text a b c a b c a b a 照合状況 × ◎ 〇 〇 〇 〇 〇
BM法 skip関数 キーワードの末尾から何文字目に目的の文字が存在するかを 示す関数 (もしキーワード内に目的の文字がなければキーワードの長さ がskip関数の値となる) 例:abcaba 文字 Skip関数 a
2 b 1 c 3 その他の文字 6
AC法 マシンACと呼ばれる一種の有限オートマトンを複数のキーワー ドから構成し、これに入力としてテキストストリングを与えること で文字列照合を行う手法 ※有限オートマトン 有限個の状態の遷移と動作の組み合わせからなる「ふるまい のモデル」 現在状態から遷移しうる状態、遷移のきっかけとなる条件を列 挙することで定義される
AC法 マシンAC goto関数、failure関数、output関数からなる goto関数 入力によってどのような状態に遷移するかを示す状態遷移図 failure関数 goto関数で遷移が失敗したときにどの状態になるかを表す関 数 output関数 ある状態になったとき検出されるキーワードを表す関数
AC法 例1:{”ab”,”bc”,”bab”,”d”,”abcde”}のキーワードからなるマシン AC s f(s) 1 0 2 3 3
0 4 0 5 1 6 2 7 0 8 4 9 7 10 0 s output(s) 2 {“ab”} 4 {“bc”} 6 {“bab”,”ab”} 7 {“d”} 8 {“bc”} 9 {“d”} 10 {“abcde”} (a)goto関数 (b)failure関数 (c)output関数
AC法 例2:テキストストリング”xbabcdexを例1の入力として入れた時 の遷移 0 0 3 5 6 8 9
10 0 goto関数による 遷移 failure関数による 遷移 2 0 x b x b a c d e
本日の発表内容 全文検索 ・SimpleSearch ・KMP法 ・BM法 ・AC法