【问题标题】:How to get unigram and trigram only?如何仅获得一元和三元?
【发布时间】:2016-09-21 04:44:40
【问题描述】:

我需要得到没有二元的一元和三元

trigramTokenizer <- function(x) NGramTokenizer(x, Weka_control(min = 1, max = 3))

如何编辑此代码以获得答案

【问题讨论】:

    标签: r data-analysis


    【解决方案1】:

    一种方法是使用quanteda包中的dfm函数,如下所示,

    library(quanteda)
    dfm('I only want uni and trigrams', ngrams = c(1,3), verbose = FALSE)
    
    #Document-feature matrix of: 1 document, 10 features.
    #1 x 10 sparse Matrix of class "dfmSparse"
    #       features
    #docs    i only want uni and trigrams i_only_want only_want_uni want_uni_and uni_and_trigrams
    #  text1 1    1    1   1   1        1           1             1            1                1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-16
      相关资源
      最近更新 更多