我创建了一个术语文档矩阵“myDtm”,其中包含大量专利中包含的一组关键字。我想获得一个有序的、前 100 名、关键词频率最高的专利列表。
代码行是
myDtm <- TermDocumentMatrix(myCorpus, control = list(minWordLength = 1))
keywords <- unique(c("labor","cost","autom", "human" ,"person", "intens","reduc","machin","algorithm"))
inspect(myDtm[keywords,tail(order(colSums(v)),100)])
结果如下所示(摘录):
Terms 2435 33164 27276 1874 20447 41149 35987 21765 798 2461 19249 6822 27640
labor 0 0 0 0 1 0 0 0 0 0 0 0 2
cost 11 0 0 0 13 0 0 0 2 9 0 0 9
autom 0 0 0 0 26 0 0 0 0 0 0 0 0
human 0 0 0 270 150 16 0 279 0 0 54 0 1
person 0 29 0 0 46 3 0 0 0 0 0 0 1
intens 0 0 0 1 0 0 0 0 0 0 0 0 41
reduc 8 0 8 9 13 289 2 12 12 305 292 0 44
machin 264 77 0 0 2 0 0 2 0 0 0 323 31
algorithm 0 0 8 0 0 0 1 0 2 0 0 0 95
问题:如何排除异常值,例如专利号。6822?对于异常值,我指的是仅包含一两个关键字但频率非常高的专利。我想获得看起来像专利号的前 100 名专利列表。20447 或 27640,其中包含大多数关键字。更具体地说,有没有一种说法:按关键字提及的频率对列进行排序,并确保至少 50% 的关键字被提及??
先感谢您。