خرید بک لینک

Vote count: 0

I have a corpus of 11 text documents. I have found word associations using the commands:

findAssocs(dtm, c("youngster","campaign"), corlimit=0.9) 
findAssocs(dtms, "corruption", corlimit=0.9)

dtm is a document term matrix.

 dtm <- DocumentTermMatrix(docs)

where docs is the corpus.

dtms is the document term matrix after removing 10% sparse terms.

dtms <- removeSparseTerms(dtm, 0.1)

I would like to plot the correlated terms I got against (i) 2 specific words and (ii) 1 specific word I tried following this post : Plot highly correlated words against a specific word of interest

toi <- "corruption" # term of interest
corlimit <- 0.9 #  lower correlation bound limit.
cor_0.9 <- data.frame(corr = findAssocs(tdm, toi, corlimit)[,1],terms=row.names(findAssocs(tdm, toi, corlimit)))

But unfortunately the code :

cor_0.9 <- data.frame(corr = findAssocs(tdm, toi, corlimit)[,1],terms=row.names(findAssocs(tdm, toi, corlimit)))

gives me an error :

Error in findAssocs(tdm, toi, corlimit)[, 1]:incorrect number of dimensions

This is the structure of the document term matrix:

dtm
<<DocumentTermMatrix (documents: 11, terms: 1847)>>
Non-/sparse entries: 8024/12293
Sparsity           : 61%
Maximal term length: 23
Weighting          : term frequency (tf)

and in the environemt it is of form:

dtm                 List of 6
i: int [1:8024] 1  1  1  1  1  ...
j: int [1:8024] 17 29 34 43 47 ...
v: num [1:8024] 9  4  9  5  5  ...
nrow : int 11
ncol : int 1847
dimnames: list of 2
...$ Docs : chr [1:11]  "character (0)" "character (0)" "character (0)"
...$ Terms: chr [1:1847] "campaigning"|__truncated__"a"|__"truncated"__ 
attr(*,"class") = chr [1:2] "DocumentTermMatrix" "simple_triplet_matrix"...
attr(*,"weighting") = chr [1:2] "term frequency" "tf"

How do I plot word correlations for a single word and multiple words? Please help.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 12 فروردين 1395 ساعت: 14:01

صفحه بندی