how to use stemDocument in R?

前端 未结 3 558
你的背包
你的背包 2021-01-15 08:05

update:

Thanks for help. Check comments. Because of package version, I delete the tolower and it works. I just need to find another way to make it lower.

==

相关标签:
3条回答
  • 2021-01-15 08:23

    This problem appears in tm 0.6 and has to do with using functions that are not in the list of getTransformation() from tm. The problem is that tolower just returns a character vector, and not a "PlainTextDocument" like tm_map would like. The tm packages provides the content_transformer function to take care of managing the PlainTextDocument

    fbCorpus  <- tm_map(fbCorpus, content_transformer(tolower))
    
    0 讨论(0)
  • 2021-01-15 08:23

    I had the same problem.

    If you look at the arguments for stemDocuments you can specify the language of stemming. I found by specifying "English" it solved the problem for me.

    stemDocument(language="english")
    
    0 讨论(0)
  • 2021-01-15 08:35

    You are not loading you document correctly. If you have your data in x.csv file then use following:

          > x <- read.csv(file_loc, header = TRUE) // where file_loc is the path to the csv file
          > x <- data.frame(lapply(x, as.character), stringsAsFactors=FALSE)
    
         > require(tm)
             Loading required package: tm
    
         > dd <- Corpus(DataframeSource(x))
    
          > inspect(dd)
    

    Then simply use stemDocument like below:

      fbCorpus <- tm_map(fbCorpus, stemDocument)
    
    0 讨论(0)
提交回复
热议问题