npfl103 information retrieval 2
play

NPFL103: Information Retrieval (2) Dictionaries, Tolerant retrieval, - PowerPoint PPT Presentation

Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex NPFL103: Information Retrieval (2) Dictionaries, Tolerant retrieval, Spelling correction Pavel Pecina Institute of Formal and Applied Linguistics Faculty of


  1. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex NPFL103: Information Retrieval (2) Dictionaries, Tolerant retrieval, Spelling correction Pavel Pecina Institute of Formal and Applied Linguistics Faculty of Mathematics and Physics Charles University Original slides are courtesy of Hinrich Schütze, University of Stutugart. 1 / 52 pecina@ufal.mff.cuni.cz

  2. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Contents Dictionaries Hashes and trees Wildcard queries Permuterm index k -gram index Spelling correction Levenshtein distance Soundex 2 / 52

  3. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Dictionaries 3 / 52

  4. Dictionaries 2 5 Wildcard queries 16 57 132 … Calpurnia 31 2 54 101 . . . dictionary postings The dictionary is the data structure for storing the term vocabulary. 4 6 1 2 Spelling correction Levenshtein distance Soundex Inverted index For each term t , we store a list of all documents that contain t . Brutus 1 4 / 52 174 4 11 31 45 173 Caesar − → − → − → � �� � � �� �

  5. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Dictionary as array of fixed-width entries fixed-length entry. 5 / 52 ▶ For each term, we need to store a couple of items: ▶ document frequency ▶ pointer to postings list ▶ … ▶ Assume for the time being that we can store this information in a ▶ Assume that we store these entries in an array.

  6. Dictionaries aachen 2. Which data structure do we use to locate the entry (row) in the array 4 bytes 4 bytes 20 bytes Space needed: 221 zulu … … … Wildcard queries 65 656,265 frequency Spelling correction Levenshtein distance Soundex Dictionary as array of fixed-width entries Dictionary: document term pointer to postings list a 6 / 52 − → − → − → 1. How do we look up a query term q i in this array at query time? where q i is stored?

  7. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Data structures for looking up term 1. Is there a fixed number of terms or will it keep growing? 2. What are the frequencies with which various keys will be accessed? 3. How many terms are we likely to have? 8 / 52 ▶ Two main classes of data structures: hashes and trees. ▶ Some IR systems use hashes, some use trees. ▶ Criteria for when to use hashes vs. trees:

  8. Dictionaries Wildcard queries 3. need to rehash everything periodically if vocabulary keeps growing 2. no prefix search (all terms starting with automat ) 1. no way to find minor variants ( resume vs. résumé ) 2. Lookup time is constant. 1. Lookup in a hash is faster than lookup in a tree. locate entry in fixed-width array Soundex Hashes Levenshtein distance Spelling correction 9 / 52 ▶ Each vocabulary term is hashed into an integer. ▶ Try to avoid collisions ▶ At query time, do the following: hash query term, resolve collisions, ▶ Pros: ▶ Cons:

  9. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Trees of the vocabulary 10 / 52 ▶ Trees solve the prefix problem (e.g. find all terms starting with auto ). ▶ Search is slightly slower than in hashes: O ( log M ) , where M is the size ▶ O ( log M ) only holds for balanced trees. Rebalancing is expensive. ▶ B-trees mitigate the rebalancing problem. ▶ B-tree definition: every internal node has a number of children in the interval [ a , b ] where a , b are appropriate positive integers, e.g., [2 , 4] . ▶ Simplest tree: binary tree

  10. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Binary tree example 11 / 52

  11. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex B-tree example 12 / 52

  12. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Wildcard queries 13 / 52

  13. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Wildcard queries 1. Maintain an additional tree for terms backwards 14 / 52 ▶ mon* : find all docs containing any term beginning with mon ▶ With B-tree dictionary: find all terms t in the range mon ≤ t < moo ▶ *mon : find all docs containing any term ending with mon 2. Retrieve all terms t in the range: nom ≤ t < non ▶ Result: A set of terms that are matches for wildcard query ▶ Then retrieve documents that contain any of these terms

  14. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex How to handle * in the middle of a term and intersect the two sets of terms (expensive). B-tree where $ is a special symbol 16 / 52 ▶ Example: m*nchen ▶ Simple approach: We look up m* and *nchen in the backward B-tree ▶ Alternative: permuterm index ▶ Basic idea: Rotate every wildcard query so that * occurs at the end. ▶ Store each of these rotations in the dictionary, say, in a B-tree ▶ For term hello: add hello$ , ello$h , llo$he , lo$hel , and o$hell to the

  15. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex 17 / 52 Permuterm → term mapping

  16. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Permuterm index 18 / 52 ▶ For hello, we’ve stored: hello$ , ello$h , llo$he , lo$hel , and o$hell ▶ Qveries: ▶ For X, look up X$ ▶ For X*, look up $X* ▶ For *X, look up X$* ▶ For *X*, look up X* ▶ For X*Y, look up Y$X* ▶ Example: For hel*o , look up o$hel*

  17. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Processing a lookup in the permuterm index compared to a regular B-tree (empirical estimation). 19 / 52 ▶ Rotate query wildcard to the right ▶ Use B-tree lookup as before ▶ Problem: Permuterm more than quadruples the size of the dictionary

  18. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex k -gram indexes in a term (2-grams are called 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$ the bigram. 21 / 52 ▶ More space-efgicient than permuterm index ▶ Enumerate all character k -grams (sequence of k characters) occurring ▶ Example: from “ April is the cruelest month ” we get the bigrams: ▶ $ is a special word boundary symbol, as before. ▶ Maintain an inverted index from bigrams to the terms that contain

  19. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Postings list in a 3-gram inverted index etr beetroot metric petrify retrieval 22 / 52 ✲ ✲ ✲ ✲

  20. Dictionaries 4 retrieval petrify metric beetroot etr 174 173 45 31 Wildcard queries 11 2 1 Spelling correction Levenshtein distance Soundex k -gram (bigram, trigram, …) indexes query consisting of terms Brutus 23 / 52 ▶ Note that we now have two difgerent types of inverted indexes ▶ The term-document inverted index for finding documents based on a − → ▶ The k -gram index for finding terms based on a query k -grams ✲ ✲ ✲ ✲

  21. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Processing wildcarded terms in a bigram index …but also many “false positives” like moon. 24 / 52 ▶ Qvery mon* can now be run as: $m and mo and on ▶ Gets us all terms with the prefix mon … ▶ We must postfilter these terms against query. ▶ Surviving terms are then looked up in term-document inverted index. ▶ k -gram index vs. permuterm index ▶ k -gram index is more space efgicient. ▶ Permuterm index doesn’t require postfiltering.

  22. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Exercise which accents to use for the French words for university and Geneva. operator works only on whole words, not parts of words.” 25 / 52 ▶ Google has very limited support for wildcard queries. ▶ Qvery example which doesn’t work well on Google: [gen* universit* ] ▶ Intention: you are looking for the University of Geneva, but don’t know ▶ According to Google search basics, 2010-04-29: “Note that the * ▶ But this is not entirely true. Try [pythag*] and [m*nchen] ▶ Exercise: Why doesn’t Google fully support wildcard queries?

  23. Dictionaries Wildcard queries allowed, users will use them a lot. university or genève université or general universities or … 26 / 52 Processing wildcard queries in the term-document index Soundex Levenshtein distance Spelling correction ▶ Problem 1: Potential execution of a large number of Boolean queries. ▶ Most straightforward semantics: Conjunction of disjunctions ▶ For [gen* universit*] : geneva university or geneva université or genève ▶ Very expensive ▶ Problem 2: Users hate to type. ▶ If abbreviated queries like [pyth* theo*] for [pythagoras’ theorem] are ▶ This would significantly increase the cost of answering queries. ▶ Somewhat alleviated by Google Suggest

  24. Dictionaries Wildcard queries Spelling correction Levenshtein distance Soundex Spelling correction 27 / 52

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend