R.temis (version 0.1.3)

concordances: concordances

Description

Print documents which contain one or more terms and return a sub-corpus with these documents.

Usage

concordances(corpus, dtm, terms, all = FALSE)

Arguments

corpus

A Corpus object.

dtm

A DocumentTermMatrix object corresponding to corpus.

terms

One of more terms appearing in dtm.

all

Whether only documents containing all terms should be printed. By default, documents need to contain at least one of the terms.

Value

Corpus object (invisibly).

Details

Occurrences of the specified terms are highlighted. If stemming or other transformations have been applied to original words using combine_terms, all original words which have been transformed to the specified terms are highlighted.

Examples

Run this code
# NOT RUN {
file <- system.file("texts", "reut21578-factiva.xml", package="tm.plugin.factiva")
corpus <- import_corpus(file, "factiva", language="en")
dtm <- build_dtm(corpus)
concordances(corpus, dtm, "oil")
concordances(corpus, dtm, c("oil", "opec"))
concordances(corpus, dtm, c("oil", "opec"), all=TRUE)

# Also works when terms have been combined
dict <- dictionary(dtm)
dtm2 <- combine_terms(dtm, dict)
concordances(corpus, dtm2, "product")

# }

Run the code above in your browser using DataLab