Definitionintro
Term-document incidence matrix
Also called term-document matrix.
A 0-1 matrix with a row for each term and a column for each document, set where the term occurs in the document.
The term-document incidence matrix of a collection is the 0-1 matrix with one row for each term and one column for each document, whose entry is 1 exactly when the term occurs in the document. Each row is a bit vector that gives the set of documents of a term, so a Boolean query is a bitwise expression over rows. The matrix is the model behind the Boolean retrieval model. For a real collection it is almost all zeros, so engines store each row as a posting list of its 1 positions, which is an inverted index.
Definition
Let be a collection of documents, each a sequence of terms, and let be its vocabulary: the distinct terms that occur in at least one document, after the same tokenization for all documents. The term-document incidence matrix is the matrix with
The row is the incidence vector of term , and the number of 1s in it is the document frequency . The column is the set of terms of , with no count and no order. The number of 1s in is the number of postings , which is at most the number of tokens.
A Boolean query maps to bit operations on rows: is , is , and NOT is the complement , with all operations bitwise over the columns. The documents that match are the columns with a 1 in the result.
Examples and non-examples
A toy collection. The toy collection of the information retrieval pages has short documents and terms, so has entries. Exactly of them are 1, so of the matrix is set. Five rows, with the columns to from left to right:
| term | ||||||||
|---|---|---|---|---|---|---|---|---|
| sorted | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 1 |
| array | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 |
| search | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
| posting | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 |
| list | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |
The query sorted AND array AND NOT search is the bitwise expression . The 1s are in columns 2 and 8, so the answer is . Document holds all three terms, and the NOT removes it. The query sorted OR search gives , the documents .
The row of "sorted" has a 1 in column 2 although ("merge sort merges two sorted runs into one sorted array") holds the term twice. The matrix records only that the term occurs, not how often.
A large collection. Manning, Raghavan and Schuetze take a collection of one million documents with 500,000 distinct terms. The matrix has entries. With about 1000 tokens in each document, at most entries are 1, so at least of the entries are 0. Such a matrix is never stored in full. Its rows are kept as sorted lists of the column numbers of their 1s, which are the posting lists.
Non-example: the term-document count matrix. The matrix with entry , the number of times occurs in , is not an incidence matrix: its entry for "sorted" and is 2. The weighted matrix with tf-idf entries of the vector space model, and the matrix that latent semantic analysis factors, are not 0-1 either. The name "term-document matrix" often means one of these weighted matrices.
Non-example: a phrase. The incidence matrix cannot answer the phrase query "list sorted". The rows of "list" and "sorted" have a common 1 only in column 4, but is "a posting list is a sorted list of document ids", where "list" is never right before "sorted". The matrix has lost the order of the words; a positional index keeps it.
Related definitions
- Posting list. The posting list of is the sorted list of the column numbers with , the sparse form of row . Its length is .
- Inverted index. The set of all rows in posting list form, with a dictionary from terms to rows, is an inverted index. The columns in sparse form are a forward index.
- Document-term matrix. The transpose , with documents as rows, is the same relation in the other orientation.
- Bitmap index. A database bitmap index is the same idea for the values of a column of a table: one bit vector for each value.
- Sparse matrix. Posting lists are the compressed sparse row form of as a sparse matrix.
- Posting list intersection. The AND of two rows, computed on their sparse forms, is the posting list intersection problem.
References
- Christopher D. Manning, Prabhakar Raghavan and Hinrich Schuetze, Introduction to Information Retrieval, Cambridge University Press, 2008, Chapter 1, Section 1.1 (the term-document incidence matrix, Boolean queries as bitwise operations on its rows, and the size of the matrix for a large collection)
- Ian H. Witten, Alistair Moffat and Timothy C. Bell, Managing Gigabytes, second edition, Morgan Kaufmann, 1999, Chapter 3 (indexing, with bitmaps and inverted files as two ways to store the same term-document relation)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag Q35WK6 Edit this page History Report an error Markdown