Chap3. Query Structures
Download
Report
Transcript Chap3. Query Structures
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
수집->document의 작성(ectosystem)
Document->internal represention->format for
matching(endosystem)
Data의
Query Side
need->query의 작성(endosystem)
Query->internal represention->format for
matching(endosystem)
Information
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
Exact와 Approximate match의 혼합
Ex) “federal funding for energy development project,
but the funding must be at least $1,000,000”
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
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)
=
?
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을 구한다
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)
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}
3.2 Boolean Queries
문제점 1: Lack of weighting mechanism
“music by Beethoven, preferably a sonata”
Sonata: 베토벤의 다른 음악 제외
Beethoven OR Sonata: 다른 작곡자 음악 포함
(Beethoven AND Sonata) OR Beethoven
Beethoven AND
대부분의 시스템에서 “Beethoven”과 거의 동일한 결
과를 얻음
문제점 2: Misstated Query (and의 선호)
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를 앞에)
3.2 Boolean Queries
문제점 4: Highly Complex Query
해결책: DNF, CNF로의 recast
Disjunctive Normal Form(DNF)
하나의 단어, 숙어 혹은 그 부정형
Conjuncts: AND에 의해 결합된 Terms
Disjuncts: OR에 의해 결합된 Conjuncts
Terms:
e.g. (concert AND dinner AND NOT play) OR
(swimming AND tennis) OR
(baseball AND NOT football)
장점:
분리된 작은 query들의 따로 처리한 각 결과를
나중에 병합
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
DNF나 CNF로 변환(transform)하는 것
Truth table을 사용
Query를
True rows => Full DNF
3.2 Boolean Queries
Normalization의
예
(A OR B) AND (C OR NOT D) AND (D OR B)
3.2 Boolean Queries
True rows of the table
Full DNF
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
Law
NOT (A AND B) = (NOT A) OR (NOT B),
NOT (A OR B) = (NOT A) AND (NOT B).
of Double Negation
NOT (NOT A) = A
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)
3.2 Boolean Queries
처리 대상의 크기 최소화
각
conjunction을 처리할 때마다 집합의 크기는 작아짐
A AND B의 경우, 최종 결과의 크기는 A를 포함하는 집
합의 크기보다 작고 동시에 B를 포함하는 집합의 크기보
다 작다
따라서,
query의 각 term에 해당하는 집합의 크기를 미
리 알 수 있다면, 작은 집합들을 먼저 처리하고 큰 집합
들을 나중에 처리하여 대상 집합을 최소화한다
3.2 Boolean Queries
문제점 5: 결과의 크기 조정
Query를 만족시키는 모든 document를 결과로 가
져오기 때문에 결과의 크기를 조정할 수 없다
해결책1: more restrictive query
해결책2: 반환 문서수의 제한 (자동/사용자 지정)
빈도수를
이용해 sort하는 경우에 문제가 될 수 있음
중요한 문서가 배제될 수도 있다
(빈도수에 의한 sorting을 해도 단어간 상대적 중
요도는 표현되지 않는다)
3.2 Boolean Queries
장점
사용이 간편하다
대부분의 사용자는 질의어로 2~3 단어만 사용
더 정확한 탐색을 위해 매우 복잡한 연산 구조를 시
도하기 보다는 적당한 성능(manual search보다는
나은)에 만족하는 경향
각
단어의 상대적 중요도를 고려하지 않아도
된다
편의성을 중시하는 사용자에게는 장점
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 모두에서 단어가 나타
나는지의 여부에 기반하여 유사도를 결정
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
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.
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의 합집합, 또는
여집합, 교집합
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
Extended Boolean Queries
: 연산의 정의
AW1 * BW2(w1=1, w2=0~1 )
S: weight에 따라 가변적인 영역
OR : S =B - A
AND : S=A - B
AND NOT : S=AB
A OR B0 = A
A OR B1 = A OR B
A AND B0 = A
A AND B1 = A AND B
A AND NOT B0 = A
A AND NOT B1 = A AND NOT B
A
B
A
B
A
B
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
B-A
A-B
1,4,5,10,17
2, 7, 8, 13, 22
2,7,8,13,22
Min distance
1, 2, 2, 2, 1
Min distance
1, 2, 1, 1, 1
0.4
0.8
2, 22
2, 8, 13, 22
1,2,4,5,10,11,17,18,19,22,23
Extended Boolean Queries
: 연산의 정의
문제점
포함될 원소수가 정수가 아닌 경우: 1.7, 1.4, …
근처
정수로 round up or down
동일 거리의 원소가 너무 많은 경우
weight가 0.6이고 S의 원소수가 4개인데 모두 거
리가 1이라면 1개는 탈락되어야 한다
Random으로 선택하면 같은 query에 대해 다른 결과
A의
논리적으로 동일한 query에 대해 다른 결과가
나올 수 있다
(A AND
B) OR (A AND C) vs. A AND (B OR C)
Exercise 6
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
결과 : fuzzy function을 계산한 값, 각
document에 대해 이 값을 계산해 낸다.
query의
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”
장점: 빈도수로부터 확률을 구하는 방법이 체계
화되어있다
Natural Language Queries
User friendly
Ungrammatical
Hard to understand for computers
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???