cleanNLP (version 1.10.0)

get_sentence: Access sentence-level annotations

Description

Access sentence-level annotations

Usage

get_sentence(annotation)

Arguments

annotation

an annotation object

Value

Returns an object of class c("tbl_df", "tbl", "data.frame") containing one row for every sentence in the corpus.

The returned data frame includes at a minimum the following columns:

  • "id" - integer. Id of the source document.

  • "sid" - integer. Sentence id.

The coreNLP backend also currently returns a column "sentiment" that gives a score from 0 (most negative) to 4 (most positive) for how positive the tone of the sentence is predicted to be.

References

Manning, Christopher D., Mihai Surdeanu, John Bauer, Jenny Finkel, Steven J. Bethard, and David McClosky. 2014. The Stanford CoreNLP Natural Language Processing Toolkit. In: Proceedings of the 52nd Annual Meeting of the Association for Computational Linguistics: System Demonstrations, pp. 55-60.

Socher, Richard, et al. "Recursive deep models for semantic compositionality over a sentiment treebank." Proceedings of the conference on empirical methods in natural language processing (EMNLP). Vol. 1631. 2013.

Examples

Run this code
# NOT RUN {
# how do the predicted sentiment scores change across the years?
require(dplyr)
get_sentence(obama) %>%
  group_by(id) %>%
  summarize(mean(sentiment), se = sd(sentiment) / sqrt(n()))

# }

Run the code above in your browser using DataCamp Workspace