我有一个 cluto 格式的文档术语矩阵:
#Document #Term #TotalItem
term-x weight-x term-y weight-y (for only nonzeros terms, a row per document)
我想从这个文件创建 DocumentTermMatrix(tm package) 而不是语料库,这可能吗?
Cluto File:
2 3 3
1 3 3 4
2 8
Row File:
car
plane
Column File:
x
y
z
解决方案:
dtm = as.DocumentTermMatrix(read_stm_CLUTO(file), weightTf);
rows <- scan("rows.txt", what="", sep="\n");
columns <- scan("columns.txt", what="", sep="\n");
dtm$dimnames = list(rows,columns);