tm_filter

0th

Percentile

Filter and Index Functions on Corpora

Interface to apply filter and index functions to corpora.

Usage
# S3 method for PCorpus
tm_filter(x, FUN, …)
# S3 method for SimpleCorpus
tm_filter(x, FUN, …)
# S3 method for VCorpus
tm_filter(x, FUN, …)
# S3 method for PCorpus
tm_index(x, FUN, …)
# S3 method for SimpleCorpus
tm_index(x, FUN, …)
# S3 method for VCorpus
tm_index(x, FUN, …)
Arguments
x

A corpus.

FUN

a filter function taking a text document or a string (if x is a SimpleCorpus) as input and returning the logical value TRUE or FALSE.

arguments to FUN.

Value

tm_filter returns a corpus containing documents where FUN matches, whereas tm_index only returns the corresponding indices.

Aliases
  • tm_filter
  • tm_filter.PCorpus
  • tm_filter.SimpleCorpus
  • tm_filter.VCorpus
  • tm_index
  • tm_index.PCorpus
  • tm_index.SimpleCorpus
  • tm_index.VCorpus
Examples
# NOT RUN {
data("crude")
# Full-text search
tm_filter(crude, FUN = function(x) any(grep("co[m]?pany", content(x))))
# }
Documentation reproduced from package tm, version 0.7-8, License: GPL-3

Community examples

Looks like there are no examples yet.