خرید بک لینک

Vote count: 0

I need to obtain pearson correlation coefficients for pairs of text documents using library("lsa"). I've done it once, and want to do it again for all my documents. Currently, I have sorted the pairs of documents in folders but I have to do this manually:

#set directory for files
dirs <- dir("/home/files", patte="[[:alnum:]]+$")
y<-NROW(dirs)

#create holder
holder<-matrix(0,nrow=y,ncol=1)

for (i in seq(along=dirs))
{
myMatrix <- textmatrix( dirs[i], stemming=TRUE, language="english",
                      minWordLength=2, maxWordLength=FALSE, minDocFreq=1)
matrix<-myMatrix
#create latent semantic space
myLSAspace = lsa(myMatrix, dims=dimcalc_share())

#display as a text matrix again
myNewMatrix = as.textmatrix(myLSAspace)

#calculate the pearson correlation of both documents. 
cor<-cor(myNewMatrix[,1], myNewMatrix[,2], method="pearson")
holder[i]<-cor
}  

This doesn't work. Maybe there is an easier way. Can I do this for a folder that has all my files[file_1, file_2...file_n] where the loop takes each pair, calculates the correlation and puts it in the folder? Note that I'm calculating cor(file_i, file_i+1) and then cor(file_i+1, file_i+2)--like a moving window that moves by one observation for each loop.

asked 27 secs ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 10 تير 1395 ساعت: 20:47

صفحه بندی