Docsity

It based summury content, Summaries of Linguistics

Partial preview of the text

Download It based summury content and more Summaries Linguistics in PDF only on Docsity!

Information Storage and

Retrieval (ISR)

Chapter 4

Indexing structure

and

Designing an IR System

Indexing: Basic Concepts

An index file consists of records, called index entries.

The usual unit for indexing is the word

  • Index terms - are used to look up records in a file.

Index files are much smaller than the original file. Do

you agree?

Remember Heaps Law : In 1 GB text collection the size of

a vocabulary is only 5 MB (Baeza-Yates and Ribeiro-Neto,

This size may be further reduced by Linguistic pre-

processing (like stemming & other normalization

methods).

Building Index file

An index file of a document is a file consisting of a list of index terms

and a link to one or more documents that have the index term

  • A good index file maps each keyword K i

to a set of documents D i

that contain

the keyword

Index file usually has index terms in a sorted order.

  • The sort order of the terms in the index file provides an order on a physical file

For organizing index file for a collection of documents, there are

various options available:

  • Decide what data structure and/or file structure to use. Is it sequential file,

inverted file, suffix array, signature file, etc.?

Designing an IR System

Our focus during IR system design:

  1. Improving Effectiveness of the system

The concern here is retrieving more relevant documents

for users query

Effectiveness of the system is measured in terms of

precision, recall, …

Main emphasis: Stemming, stopwords removal, weighting

schemes, matching algorithms

  1. Improving Efficiency of the system

The concern here is reducing storage space requirement,

enhancing searching time, indexing time, access time…

Main emphasis: Compression, indexing structures, space

  • time tradeoffs(adjustments)

Efficiency in IR systems

  • In the context of an IR system, the

efficiency of the system can be

measured by(Index file Evaluation Metrics):

  • (^) Indexing time: Time needed to build the index
  • (^) Indexing space: Space used during the

generation of the index

  • (^) Index storage: Space required to store the

index

  • (^) Query latency: Time interval between the

arrival of the query and the generation of the

answer

  • (^) Query throughput: Average number of queries

processed per second

Text Compression

  • Text compression is about finding ways to

represent the text in fewer bits or bytes such that

the file size is reduced

  • Advantages :

Save storage space requirement.

Speed up document transmission time

Takes less time to search the compressed text

  • Disadvantages:

Consumes computational resources (both memory space

and processor running time)

1. Huffman coding

  • Huffman coding is constructed based

on frequency of occurrence of letters in

text documents

  • The Huffman encoding algorithm picks

each time two symbols (with the

smallest frequency) to combine

D

3

D

4

D

1

D

2

Codewor

d

D 1

D 2

D 3

Developed in 1950s by David Huffman, widely used for text

compression, multimedia codec and message transmission

The problem : Given a set of n symbols and their

weights (or frequencies), construct a tree structure (a

binary tree for binary code) with the objective of

reducing memory space & decoding time per symbol.

How to construct Huffman coding?

Step 1 : Create forest of trees for each symbol, t

1

, t

2

,… t

n

Step 2 : WHILE more than one tree exist DO

Sort forest of trees according to falling probabilities of symbol

occurrence

Merge two trees t 1

and t 2

with least probabilities p 1

and p 2

Label their root with sum p 1

  • p 2

Associate binary code: 1 with the right branch and 0 with the

left branch

Step 3 : Create a unique codeword for each symbol by

traversing the tree from the root to the leaf.

Concatenate all encountered 0s and 1s together during

traversal

  • The resulting tree has a prob. of 1 in its root and

symbols in its leaf node.

Huffman code tree

Using the Huffman coding a codeword can be generated by

working down the tree, left to right. This gives the binary

equivalents for each symbol in terms of 1s and 0s.

What is the Huffman binary representation for ‘fead’?

d f

g

1

c

a b

e

How it could be if I change the position of the term or symbol g or e?

Exercise

  1. Given the following, apply the Huffman algorithm to find

an optimal binary code:

  1. Given text:

“for each rose, a rose is a rose”

Compress the above text at word level using Huffman

coding

Character: a b c d e

t

Frequency: 16 5 12 17 10 25

Lempel-Ziv Compression Algorithm

  • The multi-symbol patterns are of the form: C 0

C

1

... C

n-

C

n

.

The prefix of a pattern consists of all the pattern symbols

except the last: C

0

C

1

... C

n-

Lempel-Ziv Output: there are three options in assigning a

code to each symbol in the list:-

  1. If one-symbol pattern is not in dictionary, assign (0, symbol)
  2. If multi-symbol pattern is not in dictionary, assign

(dictionaryPrefixIndex, lastPatternSymbol)

  1. If the last input symbol or the last pattern is in the dictionary,

asign (dictionaryPrefixIndex, )

Example: LZ Compression

Encode (i.e., compress) the string ABBCBCABABCAABCAAB

using the LZ algorithm.

The compressed message is: 0A0B2C3A2A4A6B

LZ77 compression

LZ77 algorithms achieve compression by replacing

repeated occurrences of data with references to a single

copy of that data existing earlier in the uncompressed

  • by Abraham Lempel and Jacob Ziv in 1977
  • the code consists of a set of triples __

a : identifies how far back in the decoded text to look

for the upcoming text segment

b : tells how many characters to copy for the

upcoming segment

c : a new character to add to complete the next

segment

  • ex) <8,2,r>, <0,0,p>

LZ77 compression example

  • An example (compressing peter_piper_picked)

peter_piper_pick

ed

<0,0,p>

p eter_piper_picke

d

<0,0,e>

pe ter_piper_picked <0,0,t>

pet er_piper_picked <2,1,r>

peter piper_picked <0,0,>

peter_ piper_picked <6,1,i>

peter_pi per_picked <8,2,r>

peter_piper _picked <6,3,c>

peter_piper_pic Ked <0,0,k>