Computes coherence of a given paragraph/document
a character vector of
a vector of expressions that determine where to split sentences
the semantic space in which the computation is to be done (a numeric matrix where every row is a word vector)
This function applies the method described in Landauer & Dumais (1997): The local coherence is the cosine
between two adjacent sentences. The global coherence is then computed as the mean value of these local
The format of
y) should be of the kind
x <- "sentence1. sentence2. sentence3" Every sentence can also just consist of one single word.
To import a document Document.txt to from a directory for coherence computation, set your working directory to this directory using
setwd(). Then use the following command lines:
fileName1 <- "Alice_in_Wonderland.txt"
x <- readChar(fileName1, file.info(fileName1)$size)
A list of two elements; the first element (
$local) contains the local coherences as a numeric vector, the second element (
$global) contains the global coherence as a numeric.
Landauer, T.K., & Dumais, S.T. (1997). A solution to Plato's problem: The Latent Semantic Analysis theory of acquisition, induction and representation of knowledge. Psychological Review, 104, 211-240.
1 2 3 4 5 6 7 8
data(wonderland) coherence ("There was certainly too much of it in the air. Even the Duchess sneezed occasionally; and as for the baby, it was sneezing and howling alternately without a moment's pause. The only things in the kitchen that did not sneeze, were the cook, and a large cat which was sitting on the hearth and grinning from ear to ear.", tvectors=wonderland)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.