Description Usage Arguments Details Value Author(s) References See Also Examples
Computes cosine values between sentences and/or documents
1 |
x |
a character vector |
y |
a character vector |
tvectors |
the semantic space in which the computation is to be done (a numeric matrix where every row is a word vector) |
breakdown |
if |
In the traditional LSA approach, the vector D for a document (or a sentence) consisting of the words (t1, . , tn) is computed as
D = ∑\limits_{i=1}^n t_n
This function computes the cosine between two documents (or sentences) or the cosine between a single word and a document (or sentence).
The format of x
(or y
) can be of the kind x <- "word1 word2 word3"
, but also of the kind x <- c("word1", "word2", "word3")
. This allows for simple copy&paste-inserting of text,
but also for using character vectors, e.g. the output of neighbors()
.
To import a document Document.txt to from a directory for comparisons, 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 numeric giving the cosine between the input sentences/documents
Fritz Günther
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.
Dennis, S. (2007). How to use the LSA Web Site. In T. K. Landauer, D. S. McNamara, S. Dennis, & W. Kintsch (Eds.), Handbook of Latent
Semantic Analysis (pp. 35-56). Mahwah, NJ: Erlbaum.
cosine
,
Cosine
,
multicos
,
multicostring
1 2 3 4 | data(wonderland)
costring("Alice was beginning to get very tired.",
"A white rabbit with a clock ran close to her.",
tvectors=wonderland)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.