boolean retrieval

27
1 Introduction to Information Retrieval(IIR) Introduction to Information Retrieval(IIR) 1. Boolean retrieval 1. Boolean retrieval Online text: Online text: http://nlp.stanford.edu/IR-book/pdf/01bool.pdf Slide based on: Slide based on: http://nlp.stanford.edu/IR-book/ppt/01intro.pptx

Upload: saireya-

Post on 15-Jul-2015

298 views

Category:

Technology


0 download

TRANSCRIPT

1

Introduction to Information Retrieval(IIR)Introduction to Information Retrieval(IIR)

1. Boolean retrieval1. Boolean retrieval

Online text: Online text: http://nlp.stanford.edu/IR-book/pdf/01bool.pdf Slide based on: Slide based on: http://nlp.stanford.edu/IR-book/ppt/01intro.pptx

2

OutlineOutline

1. 0. Introduction- What is IR?- What is IR?

1. 1. 1. 1. GreppingGrepping- Why grepping is so bad?- Why grepping is so bad?

1. 2. 1. 2. Inverted indexInverted index- to reduce the amount of memory- to reduce the amount of memory

1. 3. 1. 3. Processing queryProcessing query

1. 4. 1. 4. OptimizationOptimization- to reduce the amount of memory more- to reduce the amount of memory more

3

IntroductionIntroduction

Information Retrieval (IR)Information Retrieval (IR)::finding material of an unstructured nature that finding material of an unstructured nature that satisfies an information need from within large satisfies an information need from within large collections.collections.(term is coined by Calvin Mooers in 1948/50)(term is coined by Calvin Mooers in 1948/50)

※※searchsearchは曖昧なので避けられることも。は曖昧なので避けられることも。IIRIIRでは同義。では同義。

4

IntroductionIntroduction

Information Retrieval (IR)Information Retrieval (IR)::finding material of an unstructured nature that finding material of an unstructured nature that satisfies an satisfies an information needinformation need from within large from within large collections.collections.(term is coined by Calvin Mooers in 1948/50)(term is coined by Calvin Mooers in 1948/50)

※※searchsearchは曖昧なので避けられることも。は曖昧なので避けられることも。IIRIIRでは同義。では同義。

document a text

stored on computers.

5

computeruser

information need(p.5)information need(p.5)

information needinformation need::the topic about which the user desires to know the topic about which the user desires to know moremore

queryquery::(the text that) the user convey to the computer in (the text that) the user convey to the computer in an attempt to communicate the information needan attempt to communicate the information need

※※information needinformation needととqueryqueryの違いに注意の違いに注意

A document is A document is relevantrelevantif it is one that if it is one that the user perceivesthe user perceives as containing as containing information of value with respect to their information of value with respect to their personal information need.personal information need. information need query

resultrelevant?

type

perceive

6

ad hoc retrievalad hoc retrieval

ad hoc retrievalad hoc retrieval::対象となる文書集合対象となる文書集合(collection)(collection)はあまり変化せはあまり変化せず、ず、queryqueryが短期的に変化するが短期的に変化するIRIR。。

information filteringinformation filtering::queryqueryはあまり変化せず、はあまり変化せず、collectioncollectionが短期的に変化。が短期的に変化。

※※「アドホック検索とは? 「アドホック検索とは? - - たつをのたつをのChangeLogChangeLog」」http://chalow.net/2008-01-16-1.html

7

OutlineOutline

1. 0. 1. 0. IntroductionIntroduction- What is IR?- What is IR?

1. 1. Grepping- Why grepping is so bad?- Why grepping is so bad?

1. 2. 1. 2. Inverted indexInverted index- to reduce the amount of memory- to reduce the amount of memory

1. 3. 1. 3. Processing queryProcessing query

1. 4. 1. 4. OptimizationOptimization- reduce the amount of memory more- reduce the amount of memory more

8

1.1. Why grepping is so bad?1.1. Why grepping is so bad?

grepgrep::すべての文書を先頭から末尾までスキャンすべての文書を先頭から末尾までスキャン指定された単語を探せる指定された単語を探せる最近の高性能な最近の高性能なPCPCではある程度実用的ではある程度実用的

-> -> 大規模な大規模なcollectioncollectionの検索を高速に行うにはの検索を高速に行うには??-> -> もっと柔軟な検索条件は指定できないのかもっと柔軟な検索条件は指定できないのか??-> -> 得られた結果をランク付けできないのか得られた結果をランク付けできないのか??

--> --> Index in advance!Index in advance!

> grep -r “query” *

9

Term-document incidence matrixTerm-document incidence matrix

incidence matrixincidence matrix::各文書に出現する語に各文書に出現する語に11を、出現しない語にを、出現しない語に00を充ててを充てて生成した行列生成した行列((行行: : 語語, , 列列: : 文書文書))

incidence vectorincidence vector::matrixmatrixの各列の各列((縦列縦列))

QueryQueryの処理の処理: ex. [(A AND B) OR NOT C]: ex. [(A AND B) OR NOT C]- AND- AND条件条件: incidence vector: incidence vectorの論理積の論理積- OR- OR条件条件: incidence vector: incidence vectorの論理和の論理和- NOT- NOT条件条件: incidence vector: incidence vectorを反転させて処理を反転させて処理

10

Term-document incidence matrixTerm-document incidence matrix

term/doc L+ SD SH CLN同級生 1 1 1 1 1優等生 1 1お嬢様 1後輩 1 1クール 1 1 1 1先輩 1忌避 1ヤンデレ 1お姫様 1 1メイド 1フルート 1義妹 1バイト 1 1従姉 1宇宙人 1未来人 1超能力 1人見知り 1病弱 1 1演劇 1委員長 1図書室 1 1ヒトデ 1

kyrn Uta

11

Query: [Query: [図書室 図書室 AND AND クール クール AND NOT AND NOT 病弱病弱]]

term/doc L+ SD SH CLN同級生 1 1 1 1 1優等生 1 1お嬢様 1後輩 1 1クール 1 1 1 1先輩 1忌避 1ヤンデレ 1お姫様 1 1メイド 1フルート 1義妹 1バイト 1 1従姉 1宇宙人 1未来人 1超能力 1人見知り 1

1 1 1 1 0 0演劇 1委員長 1図書室 1 1ヒトデ 1

kyrn Uta

病弱(NOT)

12

Term-document incidence matrixTerm-document incidence matrix

Problem is ...Problem is ...- the matrix is - the matrix is too largetoo large!!- although the matrix contains too many 0s(- although the matrix contains too many 0s(sparsesparse)!)!

13

OutlineOutline

1. 0. 1. 0. IntroductionIntroduction- What is IR?- What is IR?

1. 1. 1. 1. GreppingGrepping- Why grepping is so bad?- Why grepping is so bad?

1. 2. Inverted index- to reduce the amount of memory- to reduce the amount of memory

1. 3. 1. 3. Processing queryProcessing query

1. 4. 1. 4. OptimizationOptimization- to reduce the amount of memory more- to reduce the amount of memory more

14

1.2. Inverted index1.2. Inverted index

「ごく普通の」「ごく普通の」indexindex。転置インデックスとも。。転置インデックスとも。※※indexindex自体が「逆引き」の意なので自体が「逆引き」の意なのでinvertedinvertedは本来不要は本来不要※※予め文書に予め文書にIDIDを付加しておくを付加しておく

dictionarydictionary(vocabulary,lexicon)

postingspostings

postings listpostings list:postingを並べたもの

postingposting:termを含む文書のID(docID)

termterm(word, token)

15

How to make inverted index?How to make inverted index?

1.1. 対象となる文書を取得対象となる文書を取得

2.2. テキストをテキストをtokentokenに分割に分割

3.3. 言語処理により、言語処理により、tokentokenを正規化を正規化

※※日本語の場合は日本語の場合は2.2.で形態素分析などが必要。で形態素分析などが必要。

Democracy is the worst form of government except all those other forms that have been tried from time to time.

(by Sir Winston Churchill, 1947)

Democracy / is / the / worst / form / of / government / except / all / those / other / forms / that / have / been / tried / from / time / to / time

democracy / is / the / worst / form / of / government / except / all / those / other / forms / that / have / been / tried / from / time / to / time

16

How to make inverted index?How to make inverted index?

4.4.11つのつのindexindexにまとめ、語を整列にまとめ、語を整列5.5. 重複する項目を重複する項目を11つにまとめ、つにまとめ、postingspostingsを作成を作成

※※実装実装: : ○○リストリスト, , ○○可変長配列可変長配列, , ○○連想配列連想配列, , ××固定長配列固定長配列※※dictionary on memory, postings on diskdictionary on memory, postings on disk※※postings listpostings listの長さは語が出現する文書の数の長さは語が出現する文書の数((出現頻度出現頻度))

democracy ... 1is ... 1the ... 1worst ... 1form ... 1of ... 1government ... 1except ... 1all ... 1those ... 1other ... 1forms ... 1...

follow ... 2also ... 2the ... 2guiding ... 2lights ... 2of ... 2love ... 2and ... 2devotion ... 2in ... 2women ... 2these ... 2...

all ... 1also ... 2and ... 2democracy ... 1devotion ... 2except ... 1follow ... 2form ... 1guiding ... 2...of ... 1of ... 2...

4.

all ... 1also ... 2and ... 2democracy ... 1devotion ... 2except ... 1follow ... 2form ... 1guiding ... 2government ... 1...of ... 1,2...

5.

index of doc1 index of doc2

17

OutlineOutline

1. 0. 1. 0. IntroductionIntroduction- What is IR?- What is IR?

1. 1. 1. 1. GreppingGrepping- Why grepping is so bad?- Why grepping is so bad?

1. 2. 1. 2. Inverted indexInverted index- to reduce the amount of memory- to reduce the amount of memory

1. 3. Processing query

1. 4. 1. 4. OptimizationOptimization- to reduce the amount of memory more - to reduce the amount of memory more

18

1.3. Query: [1.3. Query: [図書室 図書室 AND AND クールクール]]

処理手順処理手順::1.1. 辞書から辞書から[[図書室図書室]]を探すを探す2.2. [[図書室図書室]]ののpostings list Apostings list Aを取得を取得3.3. 辞書から辞書から[[クールクール]]を探すを探す4.4. [[クールクール]]ののpostings list Bpostings list Bを取得を取得5.5. A ∩ BA ∩ Bを計算してを計算してresultresultとするとする

... How to get intersection?... How to get intersection?

図書室 ∩ クール ... 1, 6

19

Intersection of two postings list(p.11 fig.1.6)Intersection of two postings list(p.11 fig.1.6)

postings_list intersect(postings_list p1, postings_list p

2)

{ postings_list answer; // intersectionなので、どちらかの末尾にくれば終わり。 while (p

1.current() != null && p

2.current() != null)

{ if (p

1.current().docID() == p

2.current().docID())

{ answer.add(p

1.current().docID()); // 両方に同じIDがある。

p1.next(); p

2.next(); // 次のpostingに進む。

} else if (p

1.current().docID() < p

2.current().docID())

p1.next(); // p

1のIDの方が小さいので、p

1を進める。

else p

2.next(); // p

2のIDの方が小さいので、p

2を進める。

} return answer;}

20

effectivenesseffectiveness

The quality of search results.The quality of search results.

precision(precision(精度精度//適合率適合率))::What fraction of the returned results are relevant What fraction of the returned results are relevant to the information need?to the information need?#(relevant result) / #(result)#(relevant result) / #(result)

recall(recall(再現率再現率))::What fraction of the relevant documents in the What fraction of the relevant documents in the collection were returned by the system?collection were returned by the system?# (relevant result) / # (relevant document)# (relevant result) / # (relevant document)

21

Boolean retrievalBoolean retrieval

ANDAND以外に以外にORORややNOTNOTも同様にして実装可能も同様にして実装可能 ANDAND検索は検索はprecisionprecisionが高くなるがが高くなるがrecallrecallが低くなる。が低くなる。

OROR検索は検索はprecisionprecisionが低くなるがが低くなるがrecallrecallが高くなる。が高くなる。trade-off: trade-off: precision precision ↔↔ recall recall

Q. Boolean retrievalQ. Boolean retrievalののprecisionprecisionがが11ではないのはなぜではないのはなぜ??A. A. resultresultはあくまではあくまでqueryqueryに対する結果に対する結果であって、それがであって、それがinformation needinformation needに一致しているかに一致しているか(relevant(relevantかか))を判断すを判断するのは利用者るのは利用者(the user perceives)(the user perceives)である。である。

……もう少し高度なもう少し高度なBoolean retrievalBoolean retrievalはは??-> proximity operator-> proximity operator

22

extended Boolean modelextended Boolean model

proximity operatorproximity operator::文書中で文書中でtermtermがどのくらい近接しているかを指定がどのくらい近接しているかを指定

ex.ex.Westlaw(Westlaw(http://www.westlaw.com/))で用いられる記法で用いられる記法/s: same sentence/s: same sentence/p: same paragraph/p: same paragraph/k: within /k: within kk-words-words!: trailing wildcard!: trailing wildcard

[president /s said] -> “president Obama said”, ...[president /s said] -> “president Obama said”, ...[depend!] -> “dependability”, “dependency”, ...[depend!] -> “dependability”, “dependency”, ...[twin-tail] -> “twintail”, “twin-tail”, “twin tail”[twin-tail] -> “twintail”, “twin-tail”, “twin tail”

単語指定検索の方が良い結果を返すという調査もある。単語指定検索の方が良い結果を返すという調査もある。Turtle, Natural language vs. Boolean query evaluation: a comparison Turtle, Natural language vs. Boolean query evaluation: a comparison of retrieval performance, 1994of retrieval performance, 1994

23

OutlineOutline

1. 0. 1. 0. IntroductionIntroduction- What is IR?- What is IR?

1. 1. 1. 1. GreppingGrepping- Why grepping is so bad?- Why grepping is so bad?

1. 2. 1. 2. Inverted indexInverted index- to reduce the amount of memory- to reduce the amount of memory

1. 3. 1. 3. Processing queryProcessing query

1. 4. Optimization- to reduce the amount of memory more- to reduce the amount of memory more

24

1.4. Optimizing query1.4. Optimizing query

QQ11: [: [((同級生 同級生 AND AND クールクール)) AND AND 委員長委員長]]

QQ22: [: [((同級生 同級生 AND AND 委員長委員長)) AND AND クールクール]]

QQ33: [: [((委員長 委員長 AND AND クールクール)) AND AND 同級生同級生]]

... Which query is better?... Which query is better?

25

Optimizing queryOptimizing query

途中で途中でpostings listpostings listを保持するのに必要な領域を考えるを保持するのに必要な領域を考えるQQ

11: : 同級生 同級生 AND AND クール クール ... 1, 4, 6... 1, 4, 6

QQ22: : 同級生 同級生 AND AND 委員長 委員長 ... 6... 6

QQ33: : 委員長 委員長 AND AND クール クール ... 6... 6

従って、従って、QQ22かかQQ

33が良い。が良い。

より一般には、より一般には、頻度の小さいもの頻度の小さいものから順に処理から順に処理するとよい。するとよい。

inverted indexinverted indexに予め頻度を記録に予め頻度を記録しておけば、しておけば、postings listpostings listを参照を参照しなくても頻度が分かるしなくても頻度が分かる

26

Intersection of n postings list(p.12 fig.1.7)Intersection of n postings list(p.12 fig.1.7)

postings_list intersect_opt(term t1, ..., term t

n)

{ terms terms = SortByIncreasingOrder(t

1, ..., t

n);

// 頻度が最も小さいtermのpostings listを入れ、ここから削っていく。 postings_list answer = terms.first().postings_list; terms = terms.rest(); // intersectionなので、生き残るpostingがなくなっても終わり。 while (terms != null && answer != null) { // 現在生き残っているtermとintersectionをとる。 answer = intersect(answer, terms.first().postings_list); terms = terms.rest(); // 次へ進む。 } return answer;}

27

Optimizing queryOptimizing query

QQ44: [: [((同級生 同級生 OR OR お姫様お姫様)) AND AND ((委員長 委員長 OR OR 先輩先輩)) AND AND

((メイド メイド OR OR フルートフルート))]] queryqueryのそれぞれの部分について、のそれぞれの部分について、中間で保持する中間で保持するpostings listpostings listの大の大きさを見積もり、小さい順に処理きさを見積もり、小さい順に処理

部分部分queryqueryががORORなので、それぞれなので、それぞれの頻度の和で見積もれば良いの頻度の和で見積もれば良い