Learn R Programming

cleanNLP (version 1.5.2)

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 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 (worst) to 4 (best) 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. http://nlp.stanford.edu/pubs/StanfordCoreNlp2014.pdf. 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

# how do the predicted sentiment scores change across the years?
get_sentence(obama) %>%
  group_by(id) %>%
  summarize(mean(sentiment), se = sd(sentiment) / sqrt(n()))

Run the code above in your browser using DataLab