Learn R Programming

tm (version 0.5-9.1)

tm_filter: Filter and Index Functions on Corpora

Description

Interface to apply filter and index functions to corpora.

Usage

## S3 method for class 'Corpus':
tm_filter(x, \dots, FUN = searchFullText,
          doclevel = TRUE, useMeta = FALSE)
## S3 method for class 'Corpus':
tm_index(x, \dots, FUN = searchFullText,
          doclevel = TRUE, useMeta = FALSE)

Arguments

x
A corpus.
...
Arguments to FUN.
FUN
A filter function returning a logical value.
doclevel
Logical. If the document level flag is set FUN is applied to each element of x, otherwise FUN is applied to x itself. If FUN has an attribute doclevel its value will
useMeta
Logical. Should DMetaData be passed over to FUN as argument?

Value

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

See Also

sFilter for a filter using a simple statement query language, and getFilters to list available filter and index functions.

Examples

Run this code
data("crude")
attr(searchFullText, "doclevel")
tm_filter(crude, FUN = searchFullText, "company")
tm_index(crude, FUN = searchFullText, "company")

Run the code above in your browser using DataLab