Description Usage Arguments Value Examples
A wrapper for NLP,/openNLP's named sentence parsing tools.
1 2 3 4 5 | parser(text.var, engine = "openNLP",
parse.annotator = easy_parse_annotator(),
word.annotator = word_annotator(), java.path = "java",
element.chunks = floor(2000 * (23.5/mean(sapply(text.var, nchar), na.rm =
TRUE))))
|
text.var |
The text string variable. |
engine |
The backend pat of speech tagger, either "openNLP" or "coreNLP". The default "openNLP" uses the openNLP package. If the user has the Stanford CoreNLP suite (‘http://stanfordnlp.github.io/CoreNLP/’) installed this can be used as the tagging backend instead. |
parse.annotator |
A parse annotator. See |
word.annotator |
A word annotator (only used if |
java.path |
The path the where Java is located (only used if
|
element.chunks |
The number of elements to include in a chunk. Chunks are
passed through an |
Returns a list of character vectors of parsed sentences.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ## 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
)
## openNLP parser
if(!exists('parse_ann')) {
parse_ann <- parse_annotator()
}
(x2 <- parser(txt, engine = 'openNLP', parse.annotator = parse_ann))
dev.new()
par(
mfrow = c(3, 2),
mar = c(0,0,1,1) + 0.1
)
frame(); text(.5, .5, "openNLP", cex=2)
lapply(x2[1:5], plot)
## coreNLP parser
(x <- parser(txt, engine = "coreNLP"))
par(mar = c(0,0,0,.7) + 0.2)
plot(x[[2]])
par(
mfrow = c(3, 2),
mar = c(0,0,1,1) + 0.1
)
frame(); text(.5, .5, "coreNLP", cex=2)
lapply(x[1:5], plot)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.