Blog
Information Retrieval Past Paper 2015 – BSIT 6th Term UOS (IS-472)
University of Sargodha Information Retrieval (IS-472) paper for BS IT 6th term, 2015 exam (80 marks, 2:30 hours). The paper has been retyped, and solved answers are given below for all 16 short questions and all six long questions, including tf-idf weights, cosine similarity of the three novels, inverted index construction and naïve Bayes text categorisation.
Solved answers
Q1 – Short answers (16 × 2)
i. Information retrieval: Finding material (usually documents) of an unstructured nature (usually text) that satisfies an information need from within large collections, e.g. web search.
ii. Role of the posting list: In an inverted index each term points to a postings list – the list of document IDs (often with frequencies/positions) containing that term. It lets the system find all documents for a query term directly instead of scanning every document; sorted postings allow fast merging (AND/OR).
iii. Phrase queries with an inverted index: Either a biword index (index consecutive word pairs, e.g. “stanford university”) or a positional index that stores the positions of each term in each document; the query terms must appear in adjacent positions in the same document.
iv. Stemming vs lemmatisation: Stemming chops word endings with crude rules (Porter stemmer: “studies” → “studi”). Lemmatisation uses vocabulary and morphological analysis to return the dictionary form (lemma): “studies” → “study”, “better” → “good”.
v. Ranked vs Boolean retrieval: Ranked models return documents ordered by relevance score, so users see the best results first; they handle free-text queries and avoid “feast or famine” (too many or zero results) of Boolean queries.
vi. Term frequency vs inverse document frequency: tft,d is the number of times term t occurs in document d (importance within a document). idft = log(N/dft) measures how rare the term is in the collection (importance across documents).
vii. Cosine similarity: cos(q, d) = (q · d) / (|q| |d|) – the cosine of the angle between two term-weight vectors; 1 = same direction (very similar), 0 = no common terms.
viii. Precision vs recall: Precision = relevant retrieved / total retrieved (how many results are correct). Recall = relevant retrieved / total relevant in the collection (how many relevant documents were found).
ix. Adjacency list: A representation of a graph in which each node stores a list of its neighbours; in IR, the web graph stores for each page the list of pages it links to (used in PageRank and crawling).
x. Why Jaccard is not used for scoring: Jaccard |A∩B|/|A∪B| ignores term frequency, ignores the rarity (idf) of terms and does not normalise length properly, so it gives poor relevance ranking.
xi. Effect of IDF on ranking: It increases the weight of rare terms and decreases the weight of common terms, so documents matching rare query terms rank higher. It has no effect on one-term queries.
xii. Cosine vs Euclidean distance: Euclidean distance is large for vectors of different lengths even if their term distribution is similar (e.g. a document and the same document appended to itself). Cosine depends only on direction, so it is length-normalised.
xiii. Flat vs hierarchical clustering: Flat clustering (e.g. K-means) produces one set of k clusters with no structure between them. Hierarchical clustering builds a tree (dendrogram) of nested clusters, bottom-up (agglomerative) or top-down (divisive).
xiv. Two benchmark text collections: Cranfield collection; TREC collections; also Reuters-RCV1, 20 Newsgroups, GOV2, CLEF.
xv. Key operations of a crawler: Pick a URL from the frontier, fetch the page, parse it, extract text and links, check for duplicates and robots.txt, add new URLs to the frontier, and send the page to the indexer – repeat politely.
xvi. Text categorisation: Assigning documents to predefined classes (supervised). Applications: spam filtering, news topic classification, sentiment detection, language identification, routing e-mails to departments.
Q2 – Vector space retrieval model
Documents and queries are represented as vectors in a |V|-dimensional space (one dimension per vocabulary term). Each component is a term weight, usually tf-idf:
w(t,d) = (1 + log10 tf(t,d)) × log10(N / df(t))
score(q,d) = cos(q,d) = Σ w(t,q)·w(t,d) / (|q| · |d|)Steps: build term weights for documents; represent the query in the same space; compute the cosine similarity between the query and each document (using the inverted index); return the top-k documents in decreasing order of score.
Advantages: partial matching, ranked output, simple and effective. Limitations: assumes terms are independent (no synonyms or word order) and the vocabulary can be very large.
Q3 – Inverted index construction
- Collect the documents to be indexed.
- Tokenise the text into tokens (words).
- Linguistic preprocessing: lower-casing, removing stop words, stemming/lemmatisation to produce normalised terms.
- Create (term, docID) pairs for every token.
- Sort the pairs by term and then by docID.
- Merge duplicate entries of the same term in the same document, record term frequency, and split into a dictionary (term, document frequency, pointer) and postings lists (sorted docIDs).
For large collections, block sort-based indexing (BSBI) or single-pass in-memory indexing (SPIMI) builds partial indexes on disk and merges them; distributed indexing uses MapReduce.
Example: Doc1 “new home sales”, Doc2 “home sales rise” → home: 1, 2; new: 1; rise: 2; sales: 1, 2.
Q4 – tf-idf weights
Using tf-idf = tf × idf with the idf values given in Table 2:
| Term | Doc 1 | Doc 2 | Doc 3 |
|---|---|---|---|
| car | 27 × 1.65 = 44.55 | 4 × 1.65 = 6.60 | 24 × 1.65 = 39.60 |
| auto | 3 × 2.08 = 6.24 | 33 × 2.08 = 68.64 | 0 |
| insurance | 0 | 33 × 1.62 = 53.46 | 29 × 1.62 = 46.98 |
| best | 14 × 1.6 = 22.40 | 0 | 17 × 1.6 = 27.20 |
Note: the textbook version of this example (Manning et al.) gives idf(best) = 1.5, which would make best = 21.0 and 25.5. With log-tf weighting (1 + log tf) × idf the values would be car 4.01, 2.64, 3.93; auto 3.07, 5.24, 0; insurance 0, 4.08, 3.99; best 3.43, 0, 3.57 (idf 1.6).
Q5 – Cosine similarity between the three novels
The weight vectors (affection, jealous, gossip) are already length-normalised (length ≈ 1), so cosine = dot product:
cos(SaS, PaP) = 0.996×0.993 + 0.087×0.120 + 0.017×0 = 0.989 + 0.010 + 0 ≈ 0.999
cos(SaS, WH) = 0.996×0.847 + 0.087×0.466 + 0.017×0.254 = 0.844 + 0.041 + 0.004 ≈ 0.889
cos(PaP, WH) = 0.993×0.847 + 0.120×0.466 + 0×0.254 = 0.841 + 0.056 + 0 ≈ 0.897So Sense and Sensibility and Pride and Prejudice are the most similar (0.999), while Wuthering Heights is less similar to both (≈ 0.89). (Checked in Python.)
Q6 – Major components of a web search engine
- Crawler (spider): downloads web pages by following links, respecting robots.txt, revisiting pages to keep them fresh.
- Duplicate/spam detection: removes near-duplicate and spam pages.
- Parser and indexer: tokenises and normalises text, builds the inverted index (with positions), and stores metadata, anchor text and links.
- Link analysis: computes query-independent quality scores such as PageRank from the link graph.
- Query processor: parses the user query, spell-corrects, expands it and finds matching postings.
- Ranking module: scores documents using tf-idf/BM25, proximity, PageRank, freshness and learned ranking models.
- User interface and result presentation: shows ranked results with snippets; ads system and logs for feedback.
Q7 – Naïve Bayes text categorisation and applications
Multinomial naïve Bayes: a document d is assigned to the class c that maximises
c_map = argmax_c [ log P(c) + Σ log P(t_k | c) ]
P(c) = N_c / N
P(t | c) = (T_ct + 1) / (Σ_t′ T_ct′ + |V|) (Laplace smoothing)Training: count documents per class (prior) and term occurrences per class (likelihood). Testing: for each class add the log prior and log likelihood of each term in the document; choose the highest. It assumes terms are independent given the class, yet works very well and is fast.
Alternative – KNN: represent documents as tf-idf vectors; for a test document find the k most similar training documents (cosine) and assign the majority class.
Applications: spam filtering, news/topic classification, sentiment analysis of reviews, language detection, e-mail routing, filtering adult content and vertical search.
