query structures

33
Query Structures

Upload: thimba

Post on 06-Jan-2016

39 views

Category:

Documents


3 download

DESCRIPTION

Query Structures. Boolean Queries Vector Queries Extended Boolean Queries Fuzzy Queries Probabilistic Queries c.f. Natural Language Queries, DB Queries. Query Structures. Query 의 특성 ( Document 와의 비교) 간략, 구문( syntax) 충족도가 약함 빈도수 정보가 덜 중요 Parallel Process for Matching Document Side - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Query Structures

Query Structures

Page 2: Query Structures

Boolean Queries Vector Queries Extended Boolean Queries Fuzzy Queries Probabilistic Queries c.f. Natural Language Queries, DB Queries

Page 3: Query Structures

Query Structures Query 의 특성 (Document 와의 비교 )

간략 , 구문 (syntax) 충족도가 약함 빈도수 정보가 덜 중요

Parallel Process for Matching Document Side

Data 의 수집 ->document 의 작성 (ectosystem) Document->internal represention->format for

matching(endosystem)

Query Side Information need->query 의 작성 (endosystem) Query->internal represention->format for

matching(endosystem)

Page 4: Query Structures

3.1. Matching Criteria

Exact Match Numerical or business DB

Range Match Exact match 의 확장 Natural order(numeric or alphabetic) 가 있는 항목 최소 , 최대값 사용

Approximate Match Text 나 image DB Document 가 query 를 만족하는 정도를 나타내는

척도 (measure) 가 필요 : evaluation function

Page 5: Query Structures

Exact 와 Approximate match 의 혼합 Ex) “federal funding for energy development project,

but the funding must be at least $1,000,000”

Page 6: Query Structures

3.2 Boolean Queries

Boolean Query Based on concepts from logic, or Boolean algebra (list of) Terms joined by logical connectives(AND,

OR, NOT) Boolean Query 의 예

restaurants AND (Midestern OR vegetarian) AND inexpensive

Expansion Stemming: restaurant AND (Midest OR Veget)

AND inexpens Thesaurus: Midestern -> list of specific countries

Page 7: Query Structures

3.2 Boolean Queries

Proximity Operator “icing within three words of chocolate” “if icing then chocolate”

출현 단어수의 명시 2 OF (A, B, C)

= (A AND B) OR (A AND C) OR (B AND C) 4 OF (peony, daisy, dahlia, lily, hosta, zinnia,

marigold)

= ?

Page 8: Query Structures

3.2 Boolean Queries

Query 의 의미 (query 의 결과 ) ex) A AND B: term A 와 관계가 있는 document 의

집합과 , term B 와 관계가 있는 document 의 집합의 교집합

문서집합의 생성 불린식의 각 부분을 따로 처리한 후 결합ex) “information” 과 “ retrieval” 을 모두 포함하는

문서를 구하는 과정

1. “information” 을 포함하는 문서집합 D1 을 구한다2. “retrieval” 을 포함하는 문서집합 D2 를 구한다3. D1 과 D2 를 결합해서 최종적인 D3 을 구한다

Page 9: Query Structures

3.2 Boolean Queries

집합연산 ( 결합 방법 ) U: 전체 문서 D1, D2: 패턴 P1, P2 를 포함하는 문서들의 집합

1. U-D1 은 P1 을 포함하지 않는 모든 문서집합이다(not)

2. D1∩D2 는 P1 과 P2 를 둘 다 포함하는 모든 문서의 집합이다 (and)

3. D1∪D2 는 P1 이나 P2 를 포함하는 모든 문서의 집합이다 (or)

4. D1∪D2-D1∩D2 는 P1 과 P2 를 포함하지만 동시에 둘다 포함하는 것은 제외한 모든 문서의 집합이다 (xor)

Page 10: Query Structures

3.2 Boolean Queries ex)

질의어 : {information and retrieval} or not {retrieval and science} 문서집합 : ({doc1,doc3} ∩ {doc1,doc2,doc4}) ∪

{doc1,doc2,doc3,doc4,doc5}

– ({doc1, doc2, doc4} ∩ {doc2, doc3, doc4, doc5})

= {doc1} ∪ {doc1, doc3, doc5} = {doc1, doc3, doc5}

Page 11: Query Structures

3.2 Boolean Queries

문제점 1: Lack of weighting mechanism “music by Beethoven, preferably a sonata”

Beethoven AND Sonata: 베토벤의 다른 음악 제외 Beethoven OR Sonata: 다른 작곡자 음악 포함 (Beethoven AND Sonata) OR Beethoven

대부분의 시스템에서 “ Beethoven” 과 거의 동일한 결과를 얻음

문제점 2: Misstated Query (and 의 선호 )

Page 12: Query Structures

3.2 Boolean Queries

문제점 3: 연산 순서 AND, OR

A OR A AND C NOT>AND>OR 혹은 strict left-to-right order

해결책 : 괄호명시 사람의 경우 : 의미 (semantic) 정보로 구분

coffee AND croissant OR muffin raincoat AND umbrella OR sunglasses

NOT 모든 것을 다 찾아야 하는가 ? (NOT A) AND B AND C 해결책 : B AND C 로 대상 제한 (B AND C 를 앞에 )

Page 13: Query Structures

3.2 Boolean Queries

문제점 4: Highly Complex Query 해결책 : DNF, CNF 로의 recast Disjunctive Normal Form(DNF)

Terms: 하나의 단어 , 숙어 혹은 그 부정형 Conjuncts: AND 에 의해 결합된 Terms Disjuncts: OR 에 의해 결합된 Conjuncts

e.g. (concert AND dinner AND NOT play) OR

(swimming AND tennis) OR

(baseball AND NOT football) 장점 : 분리된 작은 query 들의 따로 처리한 각

결과를 나중에 병합

Page 14: Query Structures

3.2 Boolean Queries

Full Disjunctive Normal Form Each conjunct contain all of the possible terms

(A AND B) OR (A AND NOT C)

=> (A AND B AND C) OR (A AND B AND NOT C) OR

(A AND B AND NOT C) OR (A AND NOT B AND NOT C)

Conjunctive Normal Form(CNF) e.g. (concert OR dinner OR NOT play) AND

(swimming OR tennis) AND

(baseball OR NOT football)

Normalization Query 를 DNF 나 CNF 로 변환 (transform) 하는 것 Truth table 을 사용

True rows => Full DNF

Page 15: Query Structures

3.2 Boolean Queries Normalization 의 예

(A OR B) AND (C OR NOT D) AND (D OR B)

Page 16: Query Structures

3.2 Boolean Queries True rows of the table

Full DNF

Page 17: Query Structures

3.2 Boolean Queries

Minimizing to simplest possible form 앞의 예에서 처음 두 줄은 (A AND B AND C) 로 대체

가능 기타 몇 가지 기법을 사용하여 앞의 예를 단순화한 결과

(A AND C AND D) OR (B AND C) OR (B AND (NOT D))

Full CNF 테이블의 false row 로부터 full DNF 를 구한다 DeMorgan’s Law

NOT (A AND B) = (NOT A) OR (NOT B), NOT (A OR B) = (NOT A) AND (NOT B).

Law of Double Negation NOT (NOT A) = A

Page 18: Query Structures

3.2 Boolean Queries e.g. negation of query 의 DNF 가

(A AND B AND NOT C) OR (NOT A AND C) OR

(B AND C) 이면 , Negation 을 취한 후 전개하면 아래와 같다

최종결과 : (NOT A OR NOT B OR C) AND (A OR NOT C)

AND (NOT B OR NOT C)

Page 19: Query Structures

3.2 Boolean Queries 처리 대상의 크기 최소화

각 conjunction 을 처리할 때마다 집합의 크기는 작아짐

A AND B 의 경우 , 최종 결과의 크기는 A 를 포함하는 집합의 크기보다 작고 동시에 B 를 포함하는 집합의 크기보다 작다

따라서 , query 의 각 term 에 해당하는 집합의 크기를 미리 알 수 있다면 , 작은 집합들을 먼저 처리하고 큰 집합들을 나중에 처리하여 대상 집합을 최소화한다

Page 20: Query Structures

3.2 Boolean Queries

문제점 5: 결과의 크기 조정 Query 를 만족시키는 모든 document 를 결과로

가져오기 때문에 결과의 크기를 조정할 수 없다 해결책 1: more restrictive query 해결책 2: 반환 문서수의 제한 ( 자동 / 사용자

지정 ) 빈도수를 이용해 sort 하는 경우에 문제가 될 수 있음

중요한 문서가 배제될 수도 있다

( 빈도수에 의한 sorting 을 해도 단어간 상대적 중요도는 표현되지 않는다 )

Page 21: Query Structures

3.2 Boolean Queries

장점 사용이 간편하다

대부분의 사용자는 질의어로 2~3 단어만 사용

더 정확한 탐색을 위해 매우 복잡한 연산 구조를 시도하기 보다는 적당한 성능 (manual search보다는 나은 ) 에 만족하는 경향

각 단어의 상대적 중요도를 고려하지 않아도 된다

편의성을 중시하는 사용자에게는 장점

Page 22: Query Structures

3.3 Vector Queries

Vector Model Each document is represented by a vector, or ordered list of

terms, rather than by a set of terms Boolean model 과의 차이

Term representations (weights) Methods of determining the similarity between a document and

the query Boolean model 에서는 query 와 document 모두에서 단어가

나타나는지의 여부에 기반하여 유사도를 결정

Page 23: Query Structures

3.3 Vector Queries

Similarity Evaluation : 0-1 vector, weight vector Assigning weights to document terms in a vector

frequency count ( 예외 : a, an, the, of, …) user assigning

“judging dilemma” : freely assigned weights normalization

Page 24: Query Structures

3.3 Vector Queries

Retrieval Determination fixed number(by decreasing similarity) or threshold

Impractical document 들의 components 의 대부분이 0 이다 . (vector

가 10000 개의 component(term, vocabulary) 로 구성되어 있다면 , 문서에는 그 중 몇 백개의 term 만 나타날 수 있다 )

해결책 해당 document 에 나오는 단어만 component 로 한다 . 이것이 올바르게 동작하기 위해서는… . “dimensional compatibility” - the comparison of two

documents is always based on comparing the same terms in each document.

Expansion of the compact representation is needed.

Page 25: Query Structures

Extended Boolean Queries: Boolean Query + Vector Query

두 모델의 장점 결합 Logical connectives, weights

Weighted Boolean query

Boolean operation + Weights(0.0 ~ 1.0) AW1 * BW2

Query 의 결과 : term A 와 관련된 문서의 집합 A, term B 와 관련된 문서의 집합 B 의 합집합 , 또는 여집합 , 교집합

Page 26: Query Structures

Extended Boolean Queries: Boolean Query + Vector Query

Distance Distance between the document sets A and B

corresponding to the term A and B Minimum of the distances between a pair of

elements Element: a document represented by term vector

If A contains m documents and B contains n documents, mn computations are needed

Page 27: Query Structures

Extended Boolean Queries: 연산의 정의

AW1 * BW2(w1=1, w2=0~1 ) S: weight 에 따라 가변적인 영역

OR : S =B - A

A B

AND : S=A - B

A B

AND NOT : S=AB

A B

A AND B0 = A

A AND B1 = A AND B

A OR B0 = A

A OR B1 = A OR B

A AND NOT B0 = A

A AND NOT B1 = A AND NOT B

Page 28: Query Structures

Extended Boolean Queries: 연산의 예

A:{1,4,5,10,11,15,17,18,19,23}B:{1,2,4,5,7,8,10,13,17,23} A 0.8 OR B 0.4

w1= 1 w2= 1

2, 7, 8, 13, 22

B-A

2,7,8,13,22

A-B

1, 2, 2, 2, 1

Min distance

1, 2, 1, 1, 1

Min distance

0.4

2, 220.8

2, 8, 13, 22

1,4,5,10,17

1,2,4,5,10,11,17,18,19,22,23

Page 29: Query Structures

Extended Boolean Queries: 연산의 정의

문제점 포함될 원소수가 정수가 아닌 경우 : 1.7, 1.4, …

근처 정수로 round up or down

동일 거리의 원소가 너무 많은 경우 A 의 weight 가 0.6 이고 S 의 원소수가 4 개인데

모두 거리가 1 이라면 1 개는 탈락되어야 한다 Random 으로 선택하면 같은 query 에 대해 다른 결과

논리적으로 동일한 query 에 대해 다른 결과가 나올 수 있다

(A AND B) OR (A AND C) vs. A AND (B OR C) Exercise 6

Page 30: Query Structures

Fuzzy Queries Ordinary Set vs. Fuzzy Set

Ordinary Set : sharp edge (e.g. “6feet 를 넘으면 tall”) Fuzzy Set : membership grade e.g. “degree of tallness” 에 대한 membership grade

4’5’’: 0.1, 5’8’’: 0.45, 6’2’’: 0,52, 6’10’’: 0.9

Boolean operator in fuzzy set S query 의 결과 : fuzzy function 을 계산한 값 , 각

document 에 대해 이 값을 계산해 낸다 .

Page 31: Query Structures

Probabilistic Queries Fuzzy Queries

membership grade function 은 0~1 사이의 값을 출력하는 한도 내에서 임의로 정해질 수 있다 .

Probabilistic Query the set returned from any query is supposed to

consist of documents which satisfy that query with a probability higher than a specified threshold

제약조건

장점 : 빈도수로부터 확률을 구하는 방법이 체계화되어있다

Prob(Document Satisfy) + Prob(Document not Satisfy) = “1”

Page 32: Query Structures

Natural Language Queries

User friendly Ungrammatical Hard to understand for computers

Page 33: Query Structures

IR and DB Full Text retrieval System needs to combine,

Imprecise textual element Precise numerical or other limit 기존 문서 검색 시스템과 DB 시스템의 결합 필요

각 시스템의 상호 보완적 특성에도 불구하고 단순한 결합은 성능이 좋지 않다

One Solution : OODB Model Object : set of properties

textual portions + numeric or fixed field portions image components

Can be Commercial???