Introduction To: Information Retrieval
Introduction To: Information Retrieval
Introduction to
Information Retrieval
Introduction to Information Retrieval
Information Retrieval
Information Retrieval (IR) is finding material (usually
documents) of an unstructured nature (usually text)
that satisfies an information need from within large
collections (usually stored on computers).
2
Introduction to Information Retrieval Sec. 1.1
Boolean Retrieval
Which plays of Shakespeare contain the words Brutus AND
Caesar but NOT Calpurnia?
• The way to avoid linearly scanning the text for each query is
to index the document in advance.
3
Introduction to Information Retrieval Sec. 1.1
Term-document incidence
Antony and Cleopatra Julius Caesar The Tempest Hamlet Othello Macbeth
Antony 1 1 0 0 0 1
Brutus 1 1 0 1 0 0
Caesar 1 1 0 1 1 1
Calpurnia 0 1 0 0 0 0
Cleopatra 1 0 0 0 0 0
mercy 1 0 1 1 1 1
worser 1 0 1 1 1 0
Incidence vectors
So we have a 0/1 vector for each term.
To answer query: take the vectors for Brutus, Caesar
and Calpurnia, complement the last, and then do a
bitwise AND.
110100 AND 110111 AND 101111 = 100100.
5
Introduction to Information Retrieval Sec. 1.1
Answers to query
Antony and Cleopatra, Act III, Scene ii
Agrippa [Aside to DOMITIUS ENOBARBUS]: Why, Enobarbus,
When Antony found Julius Caesar dead,
He cried almost to roaring; and he wept
When at Philippi he found Brutus slain.
6
Introduction to Information Retrieval Sec. 1.1
7
Introduction to Information Retrieval
SEARCH
ENGINE
Query Results
Corpus
Refinement
Introduction to Information Retrieval Sec. 1.1
9
Introduction to Information Retrieval Sec. 1.1
Bigger collections
Consider N = 1 million documents, each with about
1000 words.
Avg 6 bytes/word including spaces/punctuation
6GB of data in the documents.
Say there are M = 500K distinct terms among these.
10
Introduction to Information Retrieval
11
Introduction to Information Retrieval
Inverted index
For each term t, we must store a list of all documents
that contain t.
Identify each by a docID, a document serial number
Can we used fixed-size arrays for this?
Inverted index
We need variable-size postings lists
On disk, a continuous run of postings is normal and best
In memory, can use linked lists or variable length arrays
Some tradeoffs in size/ease of insertion Posting
Tokenizer
Token stream. Friends Romans Countrymen
Linguistic modules
Modified tokens. friend roman countryman
Indexer friend 2 4
roman 1 2
Inverted index.
countryman 13 16
Introduction to Information Retrieval Sec. 1.2
Doc 1 Doc 2
Terms
and
counts
Pointers 18
Introduction to Information Retrieval Sec. 1.3
19
Introduction to Information Retrieval Sec. 1.3
2 4 8 16 32 64 128 Brutus
1 2 3 5 8 13 21 34 Caesar
20
Introduction to Information Retrieval Sec. 1.3
The merge
Walk through the two postings simultaneously, in
time linear in the total number of postings entries
2 4 8 16 32 64 128 Brutus
2 8
1 2 3 5 8 13 21 34 Caesar
22
Introduction to Information Retrieval Sec. 1.3
23
Introduction to Information Retrieval Sec. 1.4
Query optimization
Brutus 2 4 8 16 32 64 128
Caesar 1 2 3 5 8 16 21 34
Calpurnia 13 16
28
Introduction to Information Retrieval
Exercise
Recommend a query
processing order for
Term Freq
(tangerine OR trees) AND eyes 213312
(marmalade OR skies) AND kaleidoscope 87009
(kaleidoscope OR eyes) marmalade 107913
skies 271658
tangerine 46653
trees 316812
29
Introduction to Information Retrieval
30
Introduction to Information Retrieval
31
Introduction to Information Retrieval
32
Introduction to Information Retrieval
33