Tolerant Retrieval. Searching the Dictionary Tolerant Retrieval. Information Retrieval & Extraction Misbhauddin 1

Similar documents
3-1. Dictionaries and Tolerant Retrieval. Most slides were adapted from Stanford CS 276 course and University of Munich IR course.

Dictionaries and tolerant retrieval CE-324 : Modern Information Retrieval Sharif University of Technology

Dictionaries and tolerant retrieval CE-324 : Modern Information Retrieval Sharif University of Technology

Dictionaries and Tolerant retrieval

Dictionaries and tolerant retrieval. Slides by Manning, Raghavan, Schutze

Recap of the previous lecture. This lecture. A naïve dictionary. Introduction to Information Retrieval. Dictionary data structures Tolerant retrieval

Recap of last time CS276A Information Retrieval

Information Retrieval

Information Retrieval

OUTLINE. Documents Terms. General + Non-English English. Skip pointers. Phrase queries

Overview. Lecture 3: Index Representation and Tolerant Retrieval. Type/token distinction. IR System components

Information Retrieval

Text Technologies for Data Science INFR Indexing (2) Instructor: Walid Magdy

Text Technologies for Data Science INFR Indexing (2) Instructor: Walid Magdy

Information Retrieval

Natural Language Processing and Information Retrieval


Introduction to Information Retrieval (Manning, Raghavan, Schutze)

Web Information Retrieval. Lecture 4 Dictionaries, Index Compression

Part 2: Boolean Retrieval Francesco Ricci

Boolean retrieval & basics of indexing CE-324: Modern Information Retrieval Sharif University of Technology

INFO 4300 / CS4300 Information Retrieval. slides adapted from Hinrich Schütze s, linked from

CSCI 5417 Information Retrieval Systems Jim Martin!

Boolean retrieval & basics of indexing CE-324: Modern Information Retrieval Sharif University of Technology

Course structure & admin. CS276A Text Information Retrieval, Mining, and Exploitation. Dictionary and postings files: a fast, compact inverted index

Lecture 2: Encoding models for text. Many thanks to Prabhakar Raghavan for sharing most content from the following slides

Information Retrieval

Data-analysis and Retrieval Boolean retrieval, posting lists and dictionaries

Information Retrieval

Part 3: The term vocabulary, postings lists and tolerant retrieval Francesco Ricci

Search Engines. Gertjan van Noord. September 17, 2018

CS347. Lecture 2 April 9, Prabhakar Raghavan

Today s topics CS347. Inverted index storage. Inverted index storage. Processing Boolean queries. Lecture 2 April 9, 2001 Prabhakar Raghavan

Preliminary draft (c)2008 Cambridge UP

Multimedia Information Extraction and Retrieval Indexing and Query Answering

Indexing and Searching

Information Retrieval and Applications

Indexing and Searching

Inverted Indexes. Indexing and Searching, Modern Information Retrieval, Addison Wesley, 2010 p. 5

A Modern spell(1) Abhinav Upadhyay EuroBSDCon 2017, Paris

Boolean Queries. Keywords combined with Boolean operators:

CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2

ΕΠΛ660. Ανάκτηση µε το µοντέλο διανυσµατικού χώρου

Multimedia Information Extraction and Retrieval Term Frequency Inverse Document Frequency

Chapter 5 Data Structures Algorithm Theory WS 2016/17 Fabian Kuhn

Stanford University Computer Science Department Solved CS347 Spring 2001 Mid-term.

Index extensions. Manning, Raghavan and Schütze, Chapter 2. Daniël de Kok

Information Retrieval

DDS Dynamic Search Trees

Introduction to. CS276: Information Retrieval and Web Search Christopher Manning and Prabhakar Raghavan. Lecture 4: Index Construction

Introduction to Information Retrieval

Lecture 3: Phrasal queries and wildcards

INDEX CONSTRUCTION 1

Birkbeck (University of London)

信息检索与搜索引擎 Introduction to Information Retrieval GESC1007

Efficiency. Efficiency: Indexing. Indexing. Efficiency Techniques. Inverted Index. Inverted Index (COSC 488)

Information Retrieval

Indexing and Searching

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

CS 525: Advanced Database Organization 04: Indexing

Data Structures and Methods. Johan Bollen Old Dominion University Department of Computer Science

LCP Array Construction

Text Analytics. Index-Structures for Information Retrieval. Ulf Leser

Information Retrieval

1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18

Introduction to. Algorithms. Lecture 5

Practice problems Set 2

Information Retrieval

Hash Table and Hashing

TRIE BASED METHODS FOR STRING SIMILARTIY JOINS

Text Analytics. Index-Structures for Information Retrieval. Ulf Leser

Recap: lecture 2 CS276A Information Retrieval

CS 245: Database System Principles

1 Dynamic Programming

Lecture Notes on Tries

Pace University. Fundamental Concepts of CS121 1

Information Retrieval

1 Dynamic Programming

CSE 562 Database Systems

Digital Libraries: Language Technologies

Chapter 13: Query Processing

Indexing. UCSB 290N. Mainly based on slides from the text books of Croft/Metzler/Strohman and Manning/Raghavan/Schutze

ECE 122. Engineering Problem Solving Using Java

Lecture 7. Transform-and-Conquer

Recall from Last Time: AVL Trees

Lecture 4: Advanced Data Structures

Lecture Notes on Tries

Information Retrieval

More on indexing CE-324: Modern Information Retrieval Sharif University of Technology

Chapter 12: Query Processing

Information Retrieval

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:

Information Retrieval. Chap 7. Text Operations

Questions. 6. Suppose we were to define a hash code on strings s by:

Hash Open Indexing. Data Structures and Algorithms CSE 373 SP 18 - KASEY CHAMPION 1

3-2. Index construction. Most slides were adapted from Stanford CS 276 course and University of Munich IR course.

COMP171. Hashing.

1 Static-to-Dynamic Transformations

Boolean Retrieval. Manning, Raghavan and Schütze, Chapter 1. Daniël de Kok

! A relational algebra expression may have many equivalent. ! Cost is generally measured as total elapsed time for

Transcription:

Tolerant Retrieval Searching the Dictionary Tolerant Retrieval Information Retrieval & Extraction Misbhauddin 1

Query Retrieval Dictionary data structures Tolerant retrieval Wild-card queries Soundex Spelling correction Information Retrieval & Extraction Misbhauddin 2

Dictionary Data Structure The dictionary data structure stores the term vocabulary, document frequency, pointers to each postings list... in what data structure? Information Retrieval & Extraction Misbhauddin 3

Dictionary Data Structure Two main choices: Hash table Tree Some IR systems use hashes, some trees Information Retrieval & Extraction Misbhauddin 4

Hash Tables Each vocabulary term is hashed to an integer Pros: Lookup is faster than for a tree: O(1) Cons: No easy way to find minor variants: judgment/judgement No prefix search [tolerant retrieval] If vocabulary keeps growing, need to occasionally do the expensive operation of rehashing everything Information Retrieval & Extraction Misbhauddin 5

Trees Simplest: binary tree More usual: B-trees Trees require a standard ordering of characters and hence strings but we standardly have one Pros: Solves the prefix problem (terms starting with hyp) Cons: Slower: O(log M) [and this requires balanced tree] Rebalancing binary trees is expensive But B-trees mitigate the rebalancing problem Information Retrieval & Extraction Misbhauddin 6

Binary Trees a-m Root n-z a-hu hy-m n-sh si-z 7 Information Retrieval & Extraction Misbhauddin 7

B-Trees Definition: Every internal node has a number of children in the interval [a,b] where a, b are appropriate natural numbers, e.g., [2,4]. a-hu hy-m n-z Information Retrieval & Extraction Misbhauddin 8

Wildcard Queries (*) Information Retrieval & Extraction Misbhauddin 9

Wildcard Queries mon*: find all docs containing any word beginning with mon (trailing wild-card queries) Easy with binary tree (or B-tree): retrieve all words in range: mon w < moo *mon: find words ending in mon : harder (leading wild-card queries) Maintain an additional B-tree for terms backwards (reverse B-tree). Can retrieve all words in range: nom w < non. Exercise: From this, how can we enumerate all terms meeting the wild-card query pro*cent? Information Retrieval & Extraction Misbhauddin 10

Query Processing At this point, we have an enumeration of all terms in the dictionary that match the wild-card query. We still have to look up the postings for each enumerated term. E.g., consider the query: se*ate ANDfil*er This may result in the execution of many Boolean AND queries. Information Retrieval & Extraction Misbhauddin 11

Index Variations for Wildcard Queries Two strategies: Permuterm indexes k-gram indexes Information Retrieval & Extraction Misbhauddin 12

Permuterm How can we handle * s in the middle of query term? co*tion We could look up co* AND *tion in a B-tree and intersect the two term sets Expensive The solution: transform wild-card queries so that the * s occur at the end This gives rise to the Permuterm Index. Information Retrieval & Extraction Misbhauddin 13

Permuterm For term hello, index under: hello$, ello$h, llo$he, lo$hel, o$hell where $ is a special symbol Queries: X lookup on X$ {Standard Query no wildcard} X* lookup on $X* {Trailing wildcard query} *X lookup on X$* {Leading wildcard query} X*Y lookup on Y$X* {Wildcard-in-the-middle query} *X* lookup on X* {Leading & Trailing wildcard query} Exercise: X*Y*Z Query = hel*o X=hel, Y=o Lookup o$hel* Information Retrieval & Extraction Misbhauddin 14

Permuterm Query Processing Rotate query wild-card to the right Now use B-tree lookup as before Permuterm problem: quadruples lexicon size (Empirical Observation) Information Retrieval & Extraction Misbhauddin 15

Bigram (k-gram) Indexes Enumerate all k-grams (sequence of k chars) occurring in any term e.g., from text April is the cruelest month we get the 2-grams (bigrams) $a, ap, pr, ri, il, l$, $i, is, s$, $t, th, he, e$, $c, cr, ru, ue, el, le, es, st, t$, $m, mo, on, nt, h$ $ is a special word boundary symbol Maintain a second inverted index from bigrams to dictionary terms that match each bigram Information Retrieval & Extraction Misbhauddin 16

Bigram Index Example The k-gram index finds terms based on a query consisting of k-grams (here k=2) $m mace madden mo on among among amortize around Information Retrieval & Extraction Misbhauddin 17

Processing Wildcards Query mon* can now be run as $m AND mo AND on Which is All terms starting with m, containing mo and containing on Gets terms that match AND version of our wildcard query But we d enumerate moon/mormon False Positives Must post-filter these terms against query Surviving enumerated terms are then looked up in the termdocument inverted index Fast, space efficient (compared to permuterm) Information Retrieval & Extraction Misbhauddin 18

Processing Wildcard Queries As before, we must execute a Boolean query for each enumerated, filtered term. Wild-cards can result in expensive query execution (very large disjunctions ) pyth* AND prog* If you encourage laziness people will respond! Type your search terms, use * if you need to. E.g., Alex* will match Alexander. Search Information Retrieval & Extraction Misbhauddin 19

Soundex Algorithm Information Retrieval & Extraction Misbhauddin 20

Soundex Class of heuristics to expand a query into phonetic equivalents Language-specific: Mainly for names Example: Chebyshev -> Tchebysheff Invented for the US Censes in 1918 Information Retrieval & Extraction Misbhauddin 21

Soundex Typical Algorithm Turn every token to be indexed into a 4-character reduced form Do the same with query terms Build and search an index on the reduced forms When the query needs a Soundex match http://www.creativyst.com/doc/articles/soundex1/soundex1.htm Information Retrieval & Extraction Misbhauddin 22

Soundex Typical Algorithm 1. Retain the first letter of the word 2. Change all occurrences of the following letters to 0 (zero) A, E, I, O, U, H, W, Y 3. Change letters to digits as follows: B, F, P, V -> 1 C, G, J, K, Q, S, X, Z, -> 2 D, T -> 3 L -> 4 M, N -> 5 R -> 6 Information Retrieval & Extraction Misbhauddin 23

Soundex Typical Algorithm 4. Remove all pairs of consecutive digits 5. Remove all zeroes from the resulting string 6. Pad the resulting string with trailing zeroes and return the first four positions, which will be of the form <Upper-case Letter> <digit> <digit> <digit> Example: Herman => H655 Will Hermann generate the same code? Information Retrieval & Extraction Misbhauddin 24

Soundex Soundex is the classic algorithm, provided by most databases (Oracle, Microsoft) Select * from hr.employee Where SOUNDEX(lastname) = SOUNDEX( Smith ) How useful is soundex? Not very for Information retrieval Lowers the precision Okay for High Recall tasks (E.g Interpol) Information Retrieval & Extraction Misbhauddin 25

Spelling Correction Information Retrieval & Extraction Misbhauddin 26

Spell Correction Correcting user queries to retrieve right answers Two Approaches Isolated Word Check each word on its own for misspelling Will not catch typos in correctly spelled words Example: Form -> From Context-Sensitive Look at surroinding words Example: I flew form hofuf to riyadh Information Retrieval & Extraction Misbhauddin 27

Query Misspellings We can either Retrieve documents indexed by the correct spelling Retrieve several suggested alternative queries with the correct spelling Example: Did you mean? Information Retrieval & Extraction Misbhauddin 28

Isolated word correction Fundamental premise there is a lexicon from which the correct spellings come Two basic choices for this A standard lexicon such as Webster s English Dictionary An industry-specific lexicon hand-maintained The lexicon of the indexed corpus E.g., all words on the web All names, acronyms etc. (Including the misspellings) Information Retrieval & Extraction Misbhauddin 29

Isolated word correction Given a lexicon and a character sequence Q, return the words in the lexicon closest to Q What s closest? Several alternatives Edit distance (Levenshtein distance) Weighted edit distance n-gram overlap Information Retrieval & Extraction Misbhauddin 30

Intro. Dynamic Programming Fibonacci Series 0, 1, 1, 2, 3, 5, 8, N t = N t-1 + N t-2 Solutions Divide and Conquer Recursion Solve the sub-problems recursively Issue - solving many sub-problems again and again Dynamic Programming Memoization Store the solution of these sub-problems so that we do not have to solve them again Information Retrieval & Extraction Misbhauddin 31

Edit Distance (Levenshtein) Given two strings S 1 and S 2, the minimum number of operations to convert one to the other Operations are typically character-level Insert, Delete, Replace, (Transposition) E.g., the edit distance from dof to dog is 1 From cat to act is 2 from cat to dog is 3 (Just 1 with transpose.) Generally found by dynamic programming Information Retrieval & Extraction Misbhauddin 32

Edit Distance (Levenshtein) S1 Gold Operation: Deletion S1 Gold Operation: Insertion S2 Old Edit Distance: 1 S2 Goaled Edit Distance: 2 S1 S2 Gold Sold Operation: Replace Edit Distance: 1 Information Retrieval & Extraction Misbhauddin 33

Edit Distance (Levenshtein): Terminology A string S = S 1, S 2, S 3, S 4, S n Caterpillar (n=11) A substring S = S 1, S 2, S 3, S 4, S k S n Caterpillar (k=3) To find the edit distance between strings S and T, we need to examine their substrings S n -> S 1 j for all j from n-1 to 1 T m -> S 1 k for all j from m-1 to 1 Information Retrieval & Extraction Misbhauddin 34

Edit Distance (Levenshtein): Function E(j, k) = D(S 1.j, T 1..k ) E(j, 0) = D(S 1.j, ) => J deletions to get an empty string => j E(0, k) = D(, T 1..k ) => K insertions => k Information Retrieval & Extraction Misbhauddin 35

Edit Distance (Levenshtein): Formula E(j, 0) = j E(0, k) = k E(j, k) = min E j 1, k + 1 deletion E j, k 1 + 1 insertion E j 1, k 1, Sj = TK Nothing to do E j 1, k 1 + 1, Sj T K Replace http://algorithms.tutorialhorizon.com/dynamic-programming-edit-distance-problem/ Information Retrieval & Extraction Misbhauddin 36

E(j, k) = min k E j 1, k + 1 deletion E j, k 1 + 1 insertion E j 1, k 1, Sj = TK Nothing to do E j 1, k 1 + 1, Sj T K Replace 4 3 2 1 gold 4 gol 3 go 2 g 1 0-0 1 2 3 4 - g go goo good 1 2 3 4 j Information Retrieval & Extraction Misbhauddin 37

Weighted Edit Distance As Edit Distance, but the weight of an operation depends on the character(s) involved Meant to capture OCR or keyboard errors Example: m more likely to be mis-typed as n than as q Therefore, replacing m by n is a smaller edit distance than by q This may be formulated as a probability model Requires weight matrix as input Modify dynamic programming to handle weights Information Retrieval & Extraction Misbhauddin 38

Weighted Edit Distance Modified Formula E(j, k) = min E j 1, k + X deletion E j, k 1 + Y insertion E j 1, k 1, Sj = TK Nothing to do E j 1, k 1 + Z, Sj T K Replace X = Cost of Deletion Y = Cost of Insertion Z = Lookup in the Weight Matrix for Cost(S j, T k ) Information Retrieval & Extraction Misbhauddin 39

Using Edit Distance Given query, first enumerate all character sequences within a preset (weighted) edit distance (e.g., 2) Intersect this set with list of correct words Show terms you found to user as suggestions Alternatively, We can look up all possible corrections in our inverted index and return all docs slow We can run with a single most likely correction The alternatives disempower the user, but save a round of interaction with the user Information Retrieval & Extraction Misbhauddin 40

Edit distance to all dictionary terms? Given a (misspelled) query do we compute its edit distance to every dictionary term? Expensive and slow Alternative? How do we cut the set of candidate dictionary terms? One possibility is to use n-gram overlap for this This can also be used by itself for spelling correction Information Retrieval & Extraction Misbhauddin 41

n-gram overlap Enumerate all the n-grams in the query string as well as in the lexicon Use the n-gram index (recall wild-card search) to retrieve all lexicon terms matching any of the query n-grams Threshold by number of matching n-grams Variants weight by keyboard layout, etc. Information Retrieval & Extraction Misbhauddin 42

Example with trigrams Suppose the text is november Trigrams are nov, ove, vem, emb, mbe, ber. The query is december Trigrams are dec, ece, cem, emb, mbe, ber. So 3 trigrams overlap (of 6 in each term) How can we turn this into a normalized measure of overlap? Information Retrieval & Extraction Misbhauddin 43

One option Jaccard coefficient A commonly-used measure of overlap Let X and Y be two sets; then the J.C. is X Ç Y / X ÈY Equals 1 when X and Y have the same elements and zero when they are disjoint X and Y don t have to be of the same size Always assigns a number between 0 and 1 Now threshold to decide if you have a match E.g., if J.C. > 0.8, declare a match Information Retrieval & Extraction Misbhauddin 44

Context-sensitive spell correction Text: I flew from Heathrow to Narita. Consider the phrase query flew form Heathrow We d like to respond Did you mean flew from Heathrow? because no docs matched the query phrase. Information Retrieval & Extraction Misbhauddin 45

Context-sensitive spell correction Need surrounding context to catch this. First idea: retrieve dictionary terms close (in weighted edit distance) to each query term Now try all possible resulting phrases with one word fixed at a time flew from heathrow fled form heathrow flea form heathrow Hit-based spelling correction: Suggest the alternative that has lots of hits. Information Retrieval & Extraction Misbhauddin 46