69
CS 572: Information Retrieval Lecture 3: Building an Index Acknowledgment: Many slides in this lecture are adapted from Chris Manning (Stanford) and Doug Oard (Maryland)

CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

CS 572: Information Retrieval

Lecture 3: Building an Index

Acknowledgment: Many slides in this lecture are adapted from Chris Manning (Stanford) and Doug Oard (Maryland)

Page 2: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Logistics/Updates

• Project 1 details posted. For now: Due Feb 12, may push back a few days.

• Please use Piazza!

1/20/2016 CS 572: Information Retrieval. Spring 2016 2

Page 3: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Lecture Plan

Building an Index (continued)– Document processing– Tokenization– Term selection Dictionary– Phrase queries– If time: One basic index optimization

1/20/2016 CS 572: Information Retrieval. Spring 2016 3

Page 4: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Recap: The Search Process

SourceSelection

Search

Query

Selection

Ranked List

Examination

Document

Delivery

Document

QueryFormulation

IR System

Indexing Index

Acquisition Collection

1/20/2016 4CS 572: Information Retrieval. Spring 2016

Page 5: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

• Study the IR black box in isolation– Input: Query– Output: Ranked list of documents– Goal: optimize the list of output documents

First Part of Course: the IR “Black Box”

Search

Query

Ranked List

1/20/2016 5CS 572: Information Retrieval. Spring 2016

Page 6: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

The IR Black BoxDocumentsQuery

Results

1/20/2016 6CS 572: Information Retrieval. Spring 2016

Page 7: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Inside The IR Black Box

DocumentsQuery

Hits

RepresentationFunction

RepresentationFunction

Query Representation Document Representation

ComparisonFunction Index

1/20/2016 7CS 572: Information Retrieval. Spring 2016

Page 8: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Basic Inverted Indexes, Boolean Queries

• Basic inverted indexes:– Structure: Dictionary and Postings

– Key step in construction: Sorting• Boolean query processing

– Intersection by linear time “merging”– Simple optimizations

Ch. 1

1/20/2016 8CS 572: Information Retrieval. Spring 2016

Page 9: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

This lecture: What Goes Into the Index?

• Processing to form the term vocabulary– Documents– Tokenization– What terms do we put in the

index?• Dictionary Implementation• Postings (basic optimization)

– If time: Faster merges: skip lists– Positional postings, phrase queries

Search

Query

Ranked List

IndexingIndex

AcquisitionCollection

1/20/2016 9CS 572: Information Retrieval. Spring 2016

Page 10: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Recall the basic indexing pipeline

Tokenizer

Token stream. Friends Romans Countrymen

Linguistic modules

Modified tokens Terms

friend roman countryman

Indexer

Inverted index.

friend

roman

countryman

2 4

2

13 16

1

Documents tobe indexed.

Friends, Romans, countrymen.

1/20/2016 10CS 572: Information Retrieval. Spring 2016

Page 11: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Parsing a document

• What format is it in?– pdf/word/excel/html?

• What language is it in?• What character set is in use?

Each of these is a classification problem later in the course.

Often done heuristically for important special cases

Sec. 2.1

1/20/2016 11CS 572: Information Retrieval. Spring 2016

What about multimedia files (docs w/ images or video?)

Page 12: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Complications: Format and Language

• Documents being indexed can include docs from many different languages– A single index may have to contain terms of several

languages.• Sometimes a document or its components can contain

multiple languages/formats– French email with a German pdf attachment.

• What is a unit document?– A file?– An email? (Perhaps one of many in an inbox.)– An email with 5 attachments?– A group of files (PPT or LaTeX as HTML pages)

Sec. 2.1

1/20/2016 12CS 572: Information Retrieval. Spring 2016

Presenter
Presentation Notes
Nontrivial issues. Requires some design decisions.
Page 13: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Tokenization

• Input: “Friends, Romans and Countrymen”• Output: Tokens

– Friends– Romans– Countrymen

• A token is an instance of a sequence of characters• Each such token is now a candidate for an index

entry, after further processing– Described below

• But what are valid tokens to emit?

Sec. 2.2.1

1/20/2016 13CS 572: Information Retrieval. Spring 2016

Tokenizer

Page 14: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Tokenization

• Issues in tokenization:– Finland’s capital →

Finland? Finlands? Finland’s?– Hewlett-Packard → Hewlett and Packard as two

tokens?• state-of-the-art: break up hyphenated sequence. • co-education• lowercase, lower-case, lower case ?• It can be effective to get the user to put in possible hyphens

– San Francisco: one token or two? • How do you decide if it should be one token?

Sec. 2.2.1

1/20/2016 14CS 572: Information Retrieval. Spring 2016

Tokenizer

Page 15: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Numbers

• 3/20/91 ==? Mar. 20, 1991 ==? 20/3/91• 55 B.C.• B-52• My PGP key is 324a3df234cb23e• (800) 234-2333

– Often have embedded spaces– Older IR systems may not index numbers

• But often very useful: think about things like looking up error codes/stacktraces on the web

• (One answer is using n-grams: next lecture)– Will often index “meta-data” separately

• Creation date, format, etc.

Sec. 2.2.1

1/20/2016 15CS 572: Information Retrieval. Spring 2016

Tokenizer

Page 16: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Tokenization: language issues

• French– L'ensemble → one token or two?

• L ? L’ ? Le ?• Want l’ensemble to match with un ensemble

– Until at least 2003, it didn’t on Google» Internationalization!

• German noun compounds are not segmented– Lebensversicherungsgesellschaftsangestellter– ‘life insurance company employee’– German retrieval systems benefit greatly from a compound splitter module

– Can give a 15% performance boost for German

Sec. 2.2.1

1/20/2016 16CS 572: Information Retrieval. Spring 2016

Tokenizer

Page 17: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Tokenization: language issues

• Chinese and Japanese languages have no spaces between words:– 莎拉波娃现在居住在美国东南部的佛罗里达。– Not always guaranteed a unique tokenization

• Further complicated in Japanese, with multiple alphabets intermingled– Dates/amounts in multiple formats

フォーチュン500社は情報不足のため時間あた$500K(約6,000万円)

Katakana Hiragana Kanji Romaji

End-user can express query entirely in hiragana!

Sec. 2.2.1

1/20/2016 17CS 572: Information Retrieval. Spring 2016

Tokenizer

Page 18: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Tokenization: language issues

• Arabic (or Hebrew) is basically written right to left, but with certain items like numbers written left to right

• Words are separated, but letter forms within a word form complex ligatures

← → ← → ← start• ‘Algeria achieved its independence in 1962 after 132

years of French occupation.’• With Unicode, the surface presentation is complex, but the stored form is

straightforward

Sec. 2.2.1

1/20/2016 18CS 572: Information Retrieval. Spring 2016

Tokenizer

Page 19: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Strings and Segments

• Remember: user wants search for concepts– But what we actually search for are character strings

• What strings best represent concepts?– In English, words are often a good choice

• Well-chosen phrases might also be helpful– In German, compounds may need to be split

• Otherwise queries using constituent words would fail– In Chinese, word boundaries are not marked

• Thissegmentationproblemissimilartothatofspeech

Tokenizer

1/20/2016 19CS 572: Information Retrieval. Spring 2016

Page 20: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Segmentation Details

• Words (from linguistics): – Morphemes are the units of meaning– Combined to make words

• Anti (disestablishmentarian) ism

• Tokens (Java String Tokenizer version):– Eugene ’s teaching ir - class .

Tokenizer

1/20/2016 20CS 572: Information Retrieval. Spring 2016

Page 21: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Longest Substring Segmentation

• Greedy algorithm based on a lexicon

• Start with a list of every possible term

• For each unsegmented string– Remove the longest single substring in the list– Repeat until no substrings are found in the list

• Can be extended to explore alternatives

1/20/2016 21CS 572: Information Retrieval. Spring 2016

Tokenizer

Page 22: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Longest Substring Example

• Possible German compound term: – washington

• List of German words:– ach, hin, hing, sei, ton, was, wasch

• Longest substring segmentation– was-hing-ton– Roughly translates as “What tone is attached?”

1/20/2016 22CS 572: Information Retrieval. Spring 2016

Tokenizer

Page 23: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Probabilistic Segmentation

• For an input word c1 c2 c3 … cn

• Try all possible partitions into w1 w2 w3 …– c1 c2 c3 … cn

– c1 c2 c3 c3 … cn

– c1 c2 c3 … cn etc.

• Choose the highest probability partition– E.g., compute Pr(w1 w2 w3 ). How? Details soon.

• Challenges: lookup, probability estimation

1/20/2016 23CS 572: Information Retrieval. Spring 2016

Tokenizer

Page 24: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Alternative: N-gram Indexing

• Consider a Chinese document c1 c2 c3 … cn

• Don’t segment (you could be wrong!)

• Instead, treat every character bigram as a termc1 c2 , c2 c3 , c3 c4 , … , cn-1 cn

• Break up queries the same way

1/20/2016 24CS 572: Information Retrieval. Spring 2016

Tokenizer

More on this later. Think why else might be useful or harmful.

Page 25: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Normalization to terms

• We need to “normalize” words in indexed text as well as query words into the same form– We want to match U.S.A. and USA

• Result is terms: a term is a (normalized) word type, which is an entry in our IR system dictionary

• We most commonly implicitly define equivalence classes of terms by, e.g., – deleting periods to form a term

• U.S.A., USA USA

– deleting hyphens to form a term• anti-discriminatory, antidiscriminatory antidiscriminatory

Sec. 2.2.3

1/20/2016 25CS 572: Information Retrieval. Spring 2016

Tokenizer

Page 26: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Normalization: other languages

• Accents: e.g., French résumé vs. resume.• Umlauts: e.g., German: Tuebingen vs. Tübingen

– Should be equivalent• Most important criterion:

– How are your users like to write their queries for these words?

• Even in languages that normally have accents, users often may not type them– Often best to normalize to a de-accented term

• Tuebingen, Tübingen, Tubingen Tubingen

Sec. 2.2.3

1/20/2016 26CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 27: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Normalization: other languages

• Normalization of things like date forms– 7月30日 vs. 7/30– Japanese use of kana vs. Chinese characters

• Tokenization and normalization may depend on the language and so is intertwined with language detection

• Crucial: Need to “normalize” indexed text as well as query terms into the same form

Morgen will ich in MIT …

Is thisGerman “mit”?

1/20/2016 27CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 28: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Case folding• Reduce all letters to lower case

– exception: upper case in mid-sentence?

• e.g., General Motors• Fed vs. fed• SAIL vs. sail

– Often best to lower case everything, since users will use lowercase regardless of ‘correct’ capitalization…

• Google example:– Query C.A.T. – #1 result is for “cat” (well, Lolcats)

not Caterpillar Inc.

Sec. 2.2.3

1/20/2016 28CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 29: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Morphology

• Inflectional morphology– Preserves part of speech– Destructions = Destruction+PLURAL– Destroyed = Destroy+PAST

• Derivational morphology– Relates parts of speech– Destructor = AGENTIVE(destroy)

1/20/2016 29CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 30: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Lemmatization

• Reduce inflectional/variant forms to base form• E.g.,

– am, are, is → be– car, cars, car's, cars' → car

• the boy's cars are different colors → the boy car be different color

• Lemmatization implies doing “proper” reduction to dictionary headword form

Sec. 2.2.4

1/20/2016 30CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 31: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Stemming• Conflates words, usually preserving meaning

– Rule-based suffix-stripping helps for English• {destroy, destroyed, destruction}: destr

– Prefix-stripping is needed in some languages• Arabic: {alselam}: selam [Root: SLM (peace)]

• Imperfect: goal is to usually be helpful– Overstemming

• {centennial,century,center}: cent– Understamming:

• {acquire,acquiring,acquired}: acquir• {acquisition}: acquis

1/20/2016 31CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 32: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Porter’s algorithm

• Commonest algorithm for stemming English– Results suggest it’s at least as good as other stemming

options

• Conventions + 5 phases of reductions– phases applied sequentially– each phase consists of a set of commands– sample convention: Of the rules in a compound

command, select the one that applies to the longest suffix.

Sec. 2.2.4

1/20/2016 32CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 33: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Typical rules in Porter

• sses → ss• ies → i• ational → ate• tional → tion

• Weight of word sensitive rules• (m>1) EMENT →

• replacement → replac• cement → cement

Sec. 2.2.4

1/20/2016 33CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 34: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Other stemmers

• Other stemmers exist, e.g., Lovins stemmer – http://www.comp.lancs.ac.uk/computing/research/stemming/general/lovins.htm

– Single-pass, longest suffix removal (about 250 rules)

• Full morphological analysis – at most modest benefits for retrieval

• Do stemming and other normalizations help?– English: very mixed results. Helps recall for some queries but harms

precision on others• E.g., operative (dentistry) ⇒ oper

– Definitely useful for Spanish, German, Finnish, Russian…• 30% performance gains for Finnish!

Sec. 2.2.4

1/20/2016 34CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 35: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Relating Words and Concepts

• Homonymy: bank (river) vs. bank (financial)– Different words are written the same way– We’d like to work with word senses rather than words

• Polysemy: fly (pilot) vs. fly (passenger)– A word can have different “shades of meaning”– Not bad for IR: often helps more than it hurts

• Synonymy: class vs. course– Causes search failures … well address this next week!

1/20/2016 35CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 36: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Thesauri and soundex

• Do we handle synonyms and homonyms?– E.g., by hand-constructed equivalence classes

• car = automobile color = colour– We can rewrite to form equivalence-class terms

• When the document contains automobile, index it under car-automobile (and vice-versa)

– Or we can expand a query• When the query contains automobile, look under car as well

• What about spelling mistakes?– One approach is soundex, which forms equivalence

classes of words based on phonetic heuristics• More in next lecture1/20/2016 36CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 37: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Word Sense Disambiguation

• Context provides clues to word meaning– “The doctor removed the appendix.”

• For each occurrence, note surrounding words– e.g., +/- 5 non-stopwords

• Group similar contexts into clusters– Based on overlaps in the words that they contain

• Separate clusters represent different senses

1/20/2016 37CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 38: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Disambiguation Example

• Consider four example sentences– The doctor removed the appendix– The appendix was incomprehensible– The doctor examined the appendix– The appendix was removed

• What clues can you find from nearby words?– Can you find enough word senses this way?– Might you find too many word senses?– What will you do when you aren’t sure?

1/20/2016 38CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 39: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Disambiguation Can Hurt

• Disambiguation tries to reduce incorrect matches– But errors can also reduce correct matches

• Ranked retrieval techniques already disambiguate– When more query terms are present, documents rank higher– Essentially, queries give each term a context

1/20/2016 39CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 40: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Phrases

• Phrases can yield more precise queries– “University of Maryland”, “solar eclipse”

• Automated phrase detection can be harmful– Bad choices result in missed matches– Therefore, we never index only phrases

• Better to index phrases and their constituent words– IR systems are good at evidence combination

• Better evidence combination ⇒ less help from phrases

• Parsing is still relatively slow and brittle– But Google is parsing (much) of text Web…

1/20/2016 40CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 41: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Lexical Phrases

• Same idea as longest substring match– But look for word (not character) sequences

• Compile a term list that includes phrases– Technical terminology can be very helpful

• Index any phrase that occurs in the list• Most effective in a limited domain

– Otherwise hard to capture most useful phrases

1/20/2016 41CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 42: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Syntactic Phrases

• Automatically construct “sentence diagrams”– Fairly good parsers are available

• Index the noun phrases– Might work for queries that focus on objects

Sentence

Noun Phrase

The quick brown fox jumped over the lazy dog’s back

Noun phrase

Det Adj Adj Noun Verb Adj NounAdjDet

Prepositional Phrase

Prep

1/20/2016 42CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 43: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

“Named Entity” Tagging

• Automatically assign “types” to words or phrases– Person, organization, location, date, money, …

• More rapid and robust than parsing

• Best algorithms use “supervised learning”– Annotate a corpus identifying entities and types– Train a probabilistic model– Apply the model to new text

1/20/2016 43CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 44: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Stop words

• With a stop list, you exclude from the dictionary entirely the commonest words. Intuition:– They have little semantic content: the, a, and, to, be– There are a lot of them: ~30% of postings for top 30 words

• But the trend is away from doing this:– Good compression techniques means the space for including stopwords

in a system is very small– Good query optimization techniques mean you pay little at query time

for including stop words.– You need them for:

• Phrase queries: “King of Denmark”• Various song titles, etc.: “Let it be”, “To be or not to be”• “Relational” queries: “flights to London”

Sec. 2.2.2

1/20/2016 44CS 572: Information Retrieval. Spring 2016

Tokenizer

Presenter
Presentation Notes
Nevertheless: “Google ignores common words and characters such as where, the, how, and other digits and letters which slow down your search without improving the results.” (Though you can explicitly ask for them to remain.)
Page 45: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Language-specificity

• Many of the above features embody transformations that are– Language-specific and– Often, application-specific

• These are “plug-in” addenda to the indexing process

• Both open source and commercial plug-ins are available for handling these

Sec. 2.2.4

1/20/2016 45CS 572: Information Retrieval. Spring 2016

Linguistic modules

Page 46: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Summary: “Term” is Whatever You Index

• Word sense• Token• Word• Stem• Character n-gram• Phrase

1/20/2016 46

Linguistic modules

Indexer

TokenizerModified tokens Terms

CS 572: Information Retrieval. Spring 2016

Page 47: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Summary (Continued)

• The key is to index the right kind of terms• Start by finding fundamental features

– So far all we have talked about are character codes– Same ideas apply to handwriting, OCR, and speech

• Combine them into easily recognized units– Words where possible, character n-grams otherwise

• Apply further processing to optimize the system– Stemming is the most commonly used technique– Some “good ideas” don’t pan out that way

1/20/2016 47CS 572: Information Retrieval. Spring 2016

Page 48: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Dictionary entries – first cut

ensemble.french

時間.japanese

MIT.english

mit.german

guaranteed.english

entries.english

sometimes.english

tokenization.english

These may be grouped by language (or not…).

More on this in ranking/query processing.

Sec. 2.2

1/20/2016 48CS 572: Information Retrieval. Spring 2016

Indexer

Page 49: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

PHRASE QUERIES AND POSITIONAL INDEXES

1/20/2016 49CS 572: Information Retrieval. Spring 2016

Page 50: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

1/20/2016 CS 572: Information Retrieval. Spring 2016

Phrase queries• Want to answer queries such as “emory

university” – as a phrase• Thus the sentence “I went to university at

Emory” is not a match. – The concept of phrase queries has proven easily

understood by users; about 10% of web queries are phrase queries

• No longer suffices to store only<term : docs> entries

50

Indexer

Page 51: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

1/20/2016 CS 572: Information Retrieval. Spring 2016

Solution 1: Biword indexes

• Index every consecutive pair of terms in the text as a phrase

• For example the text “Friends, Romans, Countrymen” would generate the biwords– friends romans– romans countrymen

• Each of these biwords is now a dictionary term

• Two-word phrase query-processing is now immediate.

51

Indexer

Page 52: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

1/20/2016 CS 572: Information Retrieval. Spring 2016

Longer phrase queries• Longer phrases are processed as we did with

wild-cards:• emory university atlanta ga can be broken

into the Boolean query on biwords:emory university AND university atlanta AND

atlanta ga

Without the docs, we cannot verify that the docs matching the above Boolean query do contain the phrase. Can have false positives!

52

Indexer

Page 53: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Extended biwords

• Parse the indexed text and perform part-of-speech-tagging (POST).• Bucket the terms into (say) Nouns (N) and articles/prepositions (X).• Call any string of terms of the form NX*N an extended biword.

– Each such extended biword is now made a term in the dictionary.

• Example: catcher in the ryeN X X N

• Query processing: parse it into N’s and X’s– Segment query into enhanced biwords– Look up in index: catcher rye

Sec. 2.4.1

1/20/2016 53CS 572: Information Retrieval. Spring 2016

Indexer

Page 54: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Issues for biword indexes

• False positives, as noted before• Index blowup due to bigger dictionary

– Infeasible for more than biwords (e.g., triwords), Too big even for biwords!

• Biword indexes are not the standard solution (for all biwords) but can be part of a combination strategy

Sec. 2.4.1

1/20/2016 54CS 572: Information Retrieval. Spring 2016

Indexer

Page 55: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

1/20/2016 CS 572: Information Retrieval. Spring 2016

Solution 2: Positional indexes

• Store, for each term, entries of the form:<number of docs containing term;doc1: position1, position2 … ;doc2: position1, position2 … ;etc.>

55

Indexer

Page 56: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

1/20/2016 CS 572: Information Retrieval. Spring 2016

Positional index example

• Can compress position values/offsets • Nevertheless, this expands postings storage

substantially

<be: 993427;1: 7, 18, 33, 72, 86, 231;2: 3, 149;4: 17, 191, 291, 430, 434;5: 363, 367, …>

Which of docs 1,2,4,5could contain “to be

or not to be”?

56

Indexer

Page 57: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

1/20/2016 CS 572: Information Retrieval. Spring 2016

Processing a phrase query

• Extract inverted index entries for each distinct term: to, be, or, not.

• Merge their doc:position lists to enumerate all positions with “to be or not to be”.– to:

• 2:1,17,74,222,551; 4:8,16,190,429,433; 7:13,23,191; ...

– be: • 1:17,19; 4:17,191,291,430,434; 5:14,19,101; ...

• Same general method for proximity searches

57

Indexer

Page 58: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

1/20/2016 CS 572: Information Retrieval. Spring 2016

Proximity queries

• LIMIT! /3 STATUTE /3 FEDERAL /2 TORT Here, /kmeans “within k words of”.

• Clearly, positional indexes can be used for such queries; biword indexes cannot.

• Exercise: Adapt the linear merge of postings to handle proximity queries. Can you make it work for any value of k?

58

Indexer

Page 59: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

1/20/2016 CS 572: Information Retrieval. Spring 2016

Positional index size

• You can compress position values/offsets

• A positional index expands postings storage substantially

• Current standard in web search because of the power and usefulness of phrase and proximity queries … whether used explicitly or implicitly in a ranking retrieval system.

59

Indexer

Page 60: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

1/20/2016 CS 572: Information Retrieval. Spring 2016

Positional index size

• Need an entry for each occurrence, not just once per document

• Index size depends on average document size– Average web page has <1000 terms– SEC filings, books, even some epic poems … easily

100,000 terms

• Consider a term with frequency 0.1%

Why?

1001100,000111000

Positional postingsPostingsDocument size

60

Indexer

Page 61: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Rules of thumb

• A positional index is 2–4 as large as a non-positional index

• Positional index size 35–50% of volume of original text

• Caveat: all of this holds for “English-like” languages

Sec. 2.4.2

1/20/2016 61CS 572: Information Retrieval. Spring 2016

Indexer

Page 62: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Combination schemes

• These two approaches can be profitably combined– For particular phrases (“Michael Jackson”, “Britney

Spears”) it is inefficient to keep on merging positional postings lists

• Even more so for phrases like “The Who”

• Williams et al. (2004) evaluate a more sophisticated mixed indexing scheme– A typical web query mixture was executed in ¼ of the

time of using just a positional index– It required 26% more space than having a positional

index alone

Sec. 2.4.3

1/20/2016 62CS 572: Information Retrieval. Spring 2016

Indexer

Page 63: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

BASIC OPTIMIZATION:

FASTER POSTINGS MERGES WITH SKIP POINTERS A.K.A. SKIP LISTS

1/20/2016 63CS 572: Information Retrieval. Spring 2016

Page 64: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Recall basic merge

• Walk through the two postings simultaneously, in time linear in the total number of postings entries

128

31

2 4 8 41 48 64

1 2 3 8 11 17 21

Brutus

Caesar2 8

If the list lengths are m and n, the merge takes O(m+n)operations.

Can we do better?Yes (if index isn’t changing too fast).

Sec. 2.3

1/20/2016 64CS 572: Information Retrieval. Spring 2016

Page 65: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Augment postings with skip pointers(at indexing time)

• Why?• To skip postings that will not figure in the search

results.• How?• Where do we place skip pointers?

1282 4 8 41 48 64

311 2 3 8 11 17 213111

41 128

Sec. 2.3

1/20/2016 65CS 572: Information Retrieval. Spring 2016

Page 66: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Query processing with skip pointers

1282 4 8 41 48 64

311 2 3 8 11 17 213111

41 128

Suppose we’ve stepped through the lists until we process 8 on each list. We match it and advance.

We then have 41 and 11 on the lower. 11 is smaller.

But the skip successor of 11 on the lower list is 31, sowe can skip ahead past the intervening postings.

Sec. 2.3

1/20/2016 66CS 572: Information Retrieval. Spring 2016

Page 67: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Where do we place skips?

• Tradeoff:– More skips → shorter skip spans ⇒ more likely to skip.

But lots of comparisons to skip pointers.– Fewer skips → few pointer comparison, but then long

skip spans ⇒ few successful skips.

Sec. 2.3

1/20/2016 67CS 572: Information Retrieval. Spring 2016

Page 68: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Placing skips

• Simple heuristic: for postings of length L, use √L evenly-spaced skip pointers.

• This ignores the distribution of query terms.• Easy if the index is relatively static; harder if L keeps

changing because of updates.

• This definitely used to help; with modern hardware it may not (Bahle et al. 2002) unless you’re memory-based– The I/O cost of loading a bigger postings list can outweigh

the gains from quicker in memory merging!

Sec. 2.3

1/20/2016 68CS 572: Information Retrieval. Spring 2016

Page 69: CS 572: Information Retrieval - Emory Universityeugene/cs572/lectures/lecture3... · 2016-01-20 · Lecture Plan Building an Index (continued) – Document processing – Tokenization

Resources for today’s lecture

• MRS Chapters 1, 2• BCC Ch 1, Sec 2.1 (can also read ahead, rest of 2 )

• Porter’s stemmer: http://www.tartarus.org/~martin/PorterStemmer/

• Skip Lists theory: Pugh (1990)– Multilevel skip lists give same O(log n) efficiency as trees

• H.E. Williams, J. Zobel, and D. Bahle. 2004. “Fast Phrase Querying with Combined Indexes”, ACM Transactions on Information Systems.http://www.seg.rmit.edu.au/research/research.php?author=4

• D. Bahle, H. Williams, and J. Zobel. Efficient phrase querying with an auxiliary index. SIGIR 2002, pp. 215-221.

1/20/2016 69CS 572: Information Retrieval. Spring 2016