coherence: Coherence of a text

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Computes coherence of a given paragraph/document

Usage

1
coherence(x,split=c(".","!","?"),tvectors=tvectors,breakdown=TRUE)

Arguments

x

a character vector of length(x) = 1 containing the document

split

a vector of expressions that determine where to split sentences

tvectors

the semantic space in which the computation is to be done (a numeric matrix where every row is a word vector)

breakdown

if TRUE, the function breakdown is applied to the input

Details

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 coherences.
The format of x (or 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)

Value

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.

Author(s)

Fritz G?nther

References

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.

See Also

cosine, Cosine, costring

Examples

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)

codymarquart/LSAfun2 documentation built on May 13, 2019, 8:48 p.m.