Suppose that we consider, for example, N most frequent words in our corpus of documents. Then, we count the word frequencies for each of the N words in a given document and put them in an N-dimensional vector that will represent that document. Then, we define a distance between two documents to be the distance (for example, Euclidean) between the two-word frequency vectors of those documents.
The problem with this solution is that only certain words represent the actual content of the book, and others need to be present in the text because of grammar rules or their general basic meaning. For example, out of the 120 most frequently encountered words in the Bible, each word is of different importance. In the following table, we have highlighted the words that have both a high frequency in the Bible and an important meaning:
- lord - used 1.00%
- god - 0.56%
|
- Israel - 0.32%
- king - 0.32%
|
- David - 0.13%
- Jesus - 0.12%
|
Â
These words are less likely to be present in mathematical texts, for example, but more likely to be present in texts concerned with religion or Christianity.
However, if we just look at the six most frequent words in the Bible, they happen to be less useful with regard to detecting the meaning of the text:
- the - 8.07%
- and - 6.51%
|
- of - 4.37%
- to - 1.72%
|
- that - 1.63%
- in - 1.60%
|
Â
Texts concerned with mathematics, literature, and other subjects will have similar frequencies for these words. Differences may result mostly from the writing style.
Therefore, to determine a similarity distance between two documents, we only need to look at the frequency counts of the important words. Some words are less important—these dimensions are better reduced, as their inclusion can lead to misinterpretation of the results in the end. Thus, what we are left to do is choose the words (dimensions) that are important to classify the documents in our corpus. For this, consult Problem 6.