Summary of Document Similarity

Share:

Description

This function summarize the calculation of similarity.

Usage

1
simSum(sim)

Arguments

sim

Similarity matrix.

Value

List of similar documents to each documents. The number of list equals to ncol(sim).

Author(s)

Masaaki TAKADA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## The function is currently defined as
function (sim) 
{
    results <- rep(0, ncol(sim))
    names(results) <- colnames(sim)
    scores <- rep(0, ncol(sim))
    for (i in 1:ncol(sim)) {
        scores[i] <- max(sim[, i])
        results[i] <- rownames(sim)[which.max(sim[, i])]
    }
    summary <- as.list(NULL, length = nrow(sim))
    for (i in 1:nrow(sim)) {
        cond <- results == rownames(sim)[i]
        summary[[i]] <- names(which(cond[order(-scores)]))
    }
    names(summary) <- rownames(sim)
    return(summary)
  }