這是一個跟進問題到this之一。在那裏,我問是否有可能以文檔特徵矩陣(quanteda-package中的dfm-class)分割ngram-features, bigrams導致兩個不同的unigrams。在(稀疏)文檔 - 特徵矩陣中拆分ngram
爲了更好的理解:我在dfm中獲得了將德文翻譯成英文的ngram。化合物(「Emissionsminderung」)在德語中很平常,但不是英語(「減排」)。
library(quanteda)
eg.txt <- c('increase in_the great plenary',
'great plenary emission_reduction',
'increase in_the emission_reduction emission_increase')
eg.corp <- corpus(eg.txt)
eg.dfm <- dfm(eg.corp)
有一個很好的answer這個例子,它適用於比較小的矩陣作爲上面的一個精絕。但是,矩陣越大,我就會不斷遇到以下內存錯誤。
> #turn the dfm into a matrix
> DF <- as.data.frame(eg.dfm)
Error in asMethod(object) :
Cholmod-error 'problem too large' at file ../Core/cholmod_dense.c, line 105
因此,有沒有解決這個的ngram-問題或處理大(稀疏)矩陣/數據幀一個以上存儲器高效的方法?先謝謝你!
真是太棒了!您的功能運行絕對平穩,快速,並且沒有任何錯誤。非常感謝你! – uyanik