Dictionary data structures for the Inverted Index

Slides:



Advertisements
Similar presentations
Indexing DNA Sequences Using q-Grams
Advertisements

Spelling Correction for Search Engine Queries Bruno Martins, Mario J. Silva In Proceedings of EsTAL-04, España for Natural Language Processing Presenter:
Dictionaries and Tolerant Retrieval Debapriyo Majumdar Information Retrieval – Spring 2015 Indian Statistical Institute Kolkata.
Lecture 4: Dictionaries and tolerant retrieval
CpSc 881: Information Retrieval. 2 Dictionaries The dictionary is the data structure for storing the term vocabulary. Term vocabulary: the data Dictionary:
Inverted Index Hongning Wang
CSCI 5417 Information Retrieval Systems Jim Martin Lecture 3 8/30/2010.
CS276A Information Retrieval
PrasadL05TolerantIR1 Tolerant IR Adapted from Lectures by Prabhakar Raghavan (Google) and Christopher Manning (Stanford)
Introduction to Information Retrieval Introduction to Information Retrieval Adapted from Christopher Manning and Prabhakar Raghavan Tolerant Retrieval.
An Introduction to IR Lecture 3 Dictionaries and Tolerant retrieval 1.
1 ITCS 6265 Lecture 3 Dictionaries and Tolerant retrieval.
Advanced topics in Computer Science Jiaheng Lu Department of Computer Science Renmin University of China
Introduction to Information Retrieval Introduction to Information Retrieval CS276: Information Retrieval and Web Search Christopher Manning and Prabhakar.
CES 514 Data Mining Feb 17, 2010 Lecture 3: The dictionary and tolerant retrieval.
Introduction to Information Retrieval Introduction to Information Retrieval Hinrich Schütze and Christina Lioma Lecture 3: Dictionaries and tolerant retrieval.
Introduction to Information Retrieval Introduction to Information Retrieval Hinrich Schütze and Christina Lioma Lecture 3: Dictionaries and tolerant retrieval.
1 Query Languages. 2 Boolean Queries Keywords combined with Boolean operators: –OR: (e 1 OR e 2 ) –AND: (e 1 AND e 2 ) –BUT: (e 1 BUT e 2 ) Satisfy e.
Index Compression Lecture 4. Recap: lecture 3 Stemming, tokenization etc. Faster postings merges Phrase queries.
Index Construction: sorting Paolo Ferragina Dipartimento di Informatica Università di Pisa Reading Chap 4.
1 INF 2914 Information Retrieval and Web Search Lecture 9: Query Processing These slides are adapted from Stanford’s class CS276 / LING 286 Information.
Text Search and Fuzzy Matching
CS347 Lecture 2 April 9, 2001 ©Prabhakar Raghavan.
PrasadL05TolerantIR1 Tolerant IR Adapted from Lectures by Prabhakar Raghavan (Yahoo and Stanford) and Christopher Manning (Stanford)
Introduction to Information Retrieval Introduction to Information Retrieval COMP4210: Information Retrieval and Search Engines Lecture 3: Dictionaries.
Inverted Index Hongning Wang Abstraction of search engine architecture User Ranker Indexer Doc Analyzer Index results Crawler Doc Representation.
Query processing: optimizations Paolo Ferragina Dipartimento di Informatica Università di Pisa Reading 2.3.
Introduction to Information Retrieval Introduction to Information Retrieval Lecture 3: Dictionaries and tolerant retrieval Related to Chapter 3:
| 1 › Gertjan van Noord2014 Zoekmachines Lecture 3: tolerant retrieval.
Introduction to Information Retrieval Introduction to Information Retrieval Lecture 3: Dictionaries and tolerant retrieval Related to Chapter 3:
Spelling correction. Spell correction Two principal uses Correcting document(s) being indexed Correcting user queries to retrieve “right” answers Two.
Spelling correction. Spell correction Two principal uses Correcting document(s) being indexed Correcting user queries to retrieve “right” answers Two.
Dictionaries and Tolerant retrieval
Information Retrieval
Introduction to Information Retrieval Introduction to Information Retrieval Modified from Stanford CS276 slides Chap. 3: Dictionaries and tolerant retrieval.
Search Engines WS 2009 / 2010 Prof. Dr. Hannah Bast Chair of Algorithms and Data Structures Department of Computer Science University of Freiburg Lecture.
Introduction to Information Retrieval Introduction to Information Retrieval Lecture 4: Skip Pointers, Dictionaries and tolerant retrieval.
Information Retrieval On the use of the Inverted Lists.
Introduction to Information Retrieval Introduction to Information Retrieval Lectures 4-6: Skip Pointers, Dictionaries and tolerant retrieval.
Information Storage & Retrieval Department of Information Management School of Information Engineering Nanjing University of Finance & Economics
Spelling correction. Spell correction Two principal uses Correcting document(s) being indexed Retrieve matching documents when query contains a spelling.
An Introduction to IR Lecture 3 Dictionaries and Tolerant retrieval 1.
Introduction to Information Retrieval Introduction to Information Retrieval CS276: Information Retrieval and Web Search Christopher Manning and Prabhakar.
Intelligent Information Retrieval
Lectures 5: Dictionaries and tolerant retrieval
Information Retrieval Christopher Manning and Prabhakar Raghavan
Query processing: optimizations
Large Scale Search: Inverted Index, etc.
Information Retrieval in Practice
Tolerant Retrieval Review Questions
Advanced Indexing Issues
Query processing: phrase queries and positional indexes
Dictionary data structures for the Inverted Index
Modified from Stanford CS276 slides
Inverted Index Hongning Wang
Prof. Paolo Ferragina, Algoritmi per "Information Retrieval"
CS 430: Information Discovery
Query Languages.
Lecture 3: Dictionaries and tolerant retrieval
INFORMATION RETRIEVAL TECHNIQUES BY DR. ADNAN ABID
Dictionary data structures for the Inverted Index
Lecture 3: Dictionaries and tolerant retrieval
Tolerant IR Adapted from Lectures by Prabhakar Raghavan (Google) and
Dictionary data structures for the Inverted Index
Query processing: phrase queries and positional indexes
INFORMATION RETRIEVAL TECHNIQUES BY DR. ADNAN ABID
INFORMATION RETRIEVAL TECHNIQUES BY DR. ADNAN ABID
INFORMATION RETRIEVAL TECHNIQUES BY DR. ADNAN ABID
Presentation transcript:

Dictionary data structures for the Inverted Index Prof. Paolo Ferragina, Algoritmi per "Information Retrieval" Dictionary data structures for the Inverted Index

This lecture “Tolerant” retrieval Brute-force approach Edit-distance, via Dyn. Prog Weighted Edit-distance, via Dyn. Prog One-error correction Idea of filtering for edit distance Wild-card queries Spelling correction Soundex

Prof. Paolo Ferragina, Algoritmi per "Information Retrieval" One-error correction

Sec. 3.3.5 The problem 1-error = insertion, deletion or substitution of one single character Farragina  Ferragina (substitution) Feragina  Ferragina (insertion) Ferrragina  Ferragina (deletion) You could have many candidates You can still deploy keyboard layout or other statistical information (web, wikipedia,…)

A possible approach Use compressed hash tables and dictionaries: D1 = { strings to be indexed } D2 = { strings of D1 with one deletion } D2 contains, for each L-length string of D1, L strings of length L-1 a total of D1-len strings Build a hash table indexing D1 and D2 Not nice, but let us continue…

An example D1 = {cat, cast, cst, dag} Sec. 3.3.5 An example D1 = {cat, cast, cst, dag} D2 = {ag [dag], ast [cast], at [cat], ca [cat], cas [cast], cat [cast], cs [cst], cst [cast], ct [cat], ct [cat], da [dag], dg [dag], st [cst]} Every string in D2 keeps a pointer to its originating string in D1 (indicated btw […]) Query(«cat»): Perfect match: Search for P in D1, 1 query [e.g.  cat] Insertion in P: Search for P in D2 , 1 query [e.g.  cast] Deletion in P: Search for P -1 char in D1 , p queries [e.g. {at,ct, ca}  No match] Substitution: Search for P -1 char in D2 , p queries [e.g. {at,ct, ca}  at (cat),ct (cat),ct (cst),ca (cat)]

A possible approach Query(P): We need 2p +2 hash computations for P Sec. 3.3.5 A possible approach Query(P): Perfect match: Search for P in D1, 1 query Insertion in P: Search for P in D2 , 1 query Deletion in P: Search for P -1 char in D1 , p queries Substitution: Search for P -1 char in D2 , p queries We need 2p +2 hash computations for P Pro: CPU efficient, no cache misses for computing P’s hashes; but O(p) cache misses to search in D1 and D2 Cons: Large space because of the many strings in D2 which must be stored because they are pointed to by the items in the hash table of D2 and used during the search.

An improvement Query(P): Every entry in the hash table of D2 stores Sec. 3.3.5 An improvement Query(P): Perfect match: Search for P in D1, 1 query Insertion in P: Search for P in D2, 1 query Deletion in P: Search for P-1 char in D1, p queries Substitution: Search for P-1 char in D2, p queries Build two hash tables: one for D1 and one logical for D2 Every entry in the hash table of D2 stores A different hash value (strong fingerprint) A pointer to the original string(s) of D1 The search in the hash table of D2 now checks the strong-hash match to return the original strings in D1 (that need a post-filter step). This induces possibly further False Positives, but if hash is strong they are a few.

Overlap vs Edit distances Prof. Paolo Ferragina, Algoritmi per "Information Retrieval" Overlap vs Edit distances

Sec. 3.2.2 K-gram index The k-gram index contains for every k-gram (here k=2) all terms including that k-gram. $m mace madden mo among amortize on among arond Append k-1 symbol $ at the front of each string, in order to generate a number L of k-grams for a string of length L.

Overlap Distance Enumerate all 2-grams in Q = mox ($m, mo, ox) Sec. 3.3.4 Overlap Distance Enumerate all 2-grams in Q = mox ($m, mo, ox) $m mace moby mo among amortize moby on among arond Use the 2-gram index to retrieve all lexicon terms matching at least one of the 2-grams in Q (mace, moby, …, among, amortize, moby,…) Select terms by number of matching 2-grams (moby) possibly depending on Q’s length and number of errors admitted

Overlap Distance versus Edit Distance Sec. 3.3.4 Overlap Distance versus Edit Distance Select terms by threshold on matching k-grams If the term is L chars long (it consists of L k-grams) If E is the number of allowed errors (E*k of the k- grams of Q might be different from term’s ones because of the E errors) So at least L – E*k of the k-grams in Q must match a dictionary term to be a candidate answer Post-filter results via edit-distance (to be sure!) Necessary but not sufficient condition !! T=$mom, Q=$omo, L-E*k=3-2*1=1, TQ = {mo,om} but EditDist = 2

Example with trigrams (K=3) Sec. 3.3.4 Example with trigrams (K=3) Suppose the term to compare is $$november Trigrams are $$n, $no, nov, ove, vem, emb, mbe, ber The query Q = $$december Trigrams are $$d, $de, dec, ece, cem, emb, mbe, ber |Q|=8, K=3, if E=1  L – E*k = 8 – 1*3 = 5 NO! |Q|=8, K=3, if E=2  L – E*k = 8 – 2*3 = 2 OK!

Fast searching for k-grams Sec. 3.3.4 Fast searching for k-grams Assume we wish to match the following bi-grams (lo, or, rd) against a 2-gram index built over a dictionary of terms. lo alone lord sloth or border lord morbid rd ardent border card Standard postings “merge” will enumerate terms with their cardinality Then choose terms if they occur >= L – k*E times.

Context-sensitive spell correction Sec. 3.3.5 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.

General issues in spell correction Sec. 3.3.5 General issues in spell correction We enumerate multiple alternatives and then need to figure out which to present to the user for “Did you mean?” Use heuristics The alternative hitting most docs Query log analysis + tweaking For especially popular, topical queries Spell-correction is computationally expensive Run only on queries that matched few docs

Other sophisticated queries Prof. Paolo Ferragina, Algoritmi per "Information Retrieval" Other sophisticated queries

Sec. 3.2 Wild-card queries: * mon*: find all docs containing words beginning with “mon”. Use a Prefix-search data structure *mon: find words ending in “mon” Maintain a prefix-search data structure for reverse terms. How can we solve the wild-card query pro*cent ?

What about * in the middle? Sec. 3.2 What about * in the middle? co*tion We could look up co* AND *tion and intersect the two lists (expensive) se*ate AND fil*er This may result in many Boolean ANDs. The solution: transform wild-card queries so that the *’s occur at the end This gives rise to the Permuterm Index.

Permuterm index For term hello, index under: Queries: Sec. 3.2.1 Permuterm index For term hello, index under: hello$, ello$h, llo$he, lo$hel, o$hell, $hello where $ is a special symbol. Queries: X lookup on X$ X* lookup on $X* *X lookup on X$* *X* lookup on X* X*Y lookup on Y$X* X*Y*Z ??? Exercise!

Permuterm query processing Sec. 3.2.1 Permuterm query processing Rotate query wild-card to the right P*Q  Q$P* Now use prefix-search data structure Permuterm problem: ≈ 4x lexicon size Empirical observation for English.

K-gram for wild-cards queries Sec. 3.2.2 K-gram for wild-cards queries Query mon* can now be run as $m AND mo AND on Gets terms that match AND version of our wildcard query. Post-filter these terms against query, using regex matching.

Prof. Paolo Ferragina, Algoritmi per "Information Retrieval" Soundex

Sec. 3.4 Soundex Class of heuristics to expand a query into phonetic equivalents Language specific – mainly for names E.g., chebyshev  tchebycheff Invented for the U.S. census in 1918

Soundex – typical algorithm Sec. 3.4 Soundex – typical algorithm Turn every token to be indexed into a reduced form consisting of 4 chars Do the same with query terms Build and search an index on the reduced forms

Soundex – typical algorithm Sec. 3.4 Soundex – typical algorithm Retain the first letter of the word. Herman  H… Change all occurrences of the following letters to '0' (zero):  'A', E', 'I', 'O', 'U', 'H', 'W', 'Y'. Herman  H0rm0n 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 H0rm0n  H06505

Soundex contd Remove all pairs of consecutive equal digits. H06505  H06505 Remove all zeros from the resulting string. H06505  H655 Pad the resulting string with trailing zeros and return the first four positions, which will be of the form <uppercase letter> <digit> <digit> <digit>. E.g., Hermann also becomes H655.

Sec. 3.4 Soundex Soundex is the classic algorithm, provided by most databases (Oracle, Microsoft, …) Not very useful – for information retrieval Okay for “high recall” tasks (e.g., Interpol), though biased to names of certain nationalities Other algorithms for phonetic matching perform much better in the context of IR

(SPELL(moriset) AND toron*to) OR SOUNDEX(chaikofski) Conclusion We have Positional inverted index (with skip pointers) Wild-card index Spell-correction Soundex We could solve queries such as (SPELL(moriset) AND toron*to) OR SOUNDEX(chaikofski)