parser: Parse Sentences

Description Usage Arguments Value Examples

Description

A wrapper for NLP,/openNLP's named sentence parsing tools.

Usage

1
2
3
parser(text.var, parse.annotator, word.annotator = word_annotator(),
  element.chunks = floor(2000 * (23.5/mean(sapply(text.var, nchar), na.rm =
  TRUE))))

Arguments

text.var

The text string variable.

parse.annotator

A parse annotator. See ?parse_annotator. Due to Java memory allocation limits the user must generate the annotator and supply it directly to parser.

word.annotator

A word annotator.

element.chunks

The number of elements to include in a chunk. Chunks are passed through an lapply and size is kept within a tolerance because of memory allocation in the tagging process with Java.

Value

Returns a list of character vectors of parsed sentences.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
txt <- c(
    "Really, I like chocolate because it is good. It smells great.",
    "Robots are rather evil and most are devoid of decency.",
    "He is my friend.",
    "Clifford the big red dog ate my lunch.",
    "Professor Johns can not teach",
    "",
    NA
)

parse_ann <- parse_annotator()
(x <- parser(txt, parse_ann))
plot(x[[2]])
par(
    mfrow = c(3, 2),
    oma = c(5,4,0,0) + 0.1,
    mar = c(0,0,1,1) + 0.1
)
lapply(x[1:5], plot)

## End(Not run)

trinker/parser documentation built on May 31, 2019, 9:41 p.m.