tm_term_score

0th

Percentile

Compute Score for Matching Terms

Compute a score based on the number of matching terms.

Usage
"tm_term_score"(x, terms, FUN = slam::row_sums) "tm_term_score"(x, terms, FUN = function(x) sum(x, na.rm = TRUE)) "tm_term_score"(x, terms, FUN = function(x) sum(x, na.rm = TRUE)) "tm_term_score"(x, terms, FUN = slam::col_sums)
Arguments
x
Either a PlainTextDocument, a term frequency as returned by termFreq, or a TermDocumentMatrix.
terms
A character vector of terms to be matched.
FUN
A function computing a score from the number of terms matching in x.
Value

A score as computed by FUN from the number of matching terms in x.

Aliases
  • tm_term_score
  • tm_term_score.DocumentTermMatrix
  • tm_term_score.term_frequency
  • tm_term_score.PlainTextDocument
  • tm_term_score.TermDocumentMatrix
Examples
data("acq")
tm_term_score(acq[[1]], c("company", "change"))
## Not run: ## Test for positive and negative sentiments
# ## install.packages("tm.lexicon.GeneralInquirer", repos="http://datacube.wu.ac.at", type="source")
# require("tm.lexicon.GeneralInquirer")
# sapply(acq[1:10], tm_term_score, terms_in_General_Inquirer_categories("Positiv"))
# sapply(acq[1:10], tm_term_score, terms_in_General_Inquirer_categories("Negativ"))
# tm_term_score(TermDocumentMatrix(acq[1:10],
#                                 control = list(removePunctuation = TRUE)),
#              terms_in_General_Inquirer_categories("Positiv"))## End(Not run)
Documentation reproduced from package tm, version 0.6-2, License: GPL-3

Community examples

Looks like there are no examples yet.