sample.fragments {textreg} | R Documentation |
Sample fragments of text to contextualize a phrase.
Description
Take a phrase, a labeling and a corpus and return text fragments containing that phrase.
Grab all phrases and then give sample of N from positive class and N from negative class. Sampling is to first sample from documents and then sample a random phrase from each of those documents.
Usage
sample.fragments(phrases, labeling, corp, N = 10, char.before = 80,
char.after = char.before, metainfo = NULL)
Arguments
phrases |
Phrases to examine (a list of strings) |
labeling |
– a vector of the same length as the corpus |
corp |
Corpus object (tm package Corpus object) |
N |
size of sample to make. |
char.before |
Number of characters of document to pull before phrase to give context. |
char.after |
As above, but trailing characters. Defaults to char.before value. |
metainfo |
– extra string to add to the printout for clarity if many such printouts are being generated. |
See Also
Other sample.fragments: is.fragment.sample
,
print.fragment.sample
Examples
library( tm )
data( bathtub )
sample.fragments( "bathtub", meta(bathtub)$meth.chl, bathtub )
[Package textreg version 0.1.5 Index]