knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
It may be safe to say that if one is reading this, one has already installed rougeR. If you haven't, though, use the following code.
devtools::install_github("LJCovingtonJr/rougeR")
rougeR can then be activated with the following:
library(rougeR)
ROUGE stands for Recall Oriented Understudy for Gisting Evaluation. It is a set of formulas used to evaluate automated document summarization systems. Based on BLEU — which is used to evaluate machine translations — ROUGE consists of the following:
rougeR currently supports ROUGE-N and -S calculations.
This vignette takes advantage of a dataset included with the rougeR package. The dataset is a subset (100 observations) of a larger dataset of BBC News articles. It can be found at rougeR/data/data.rda
and consists of three variables:
article
is the full text of the BBC News article.summary
is a human written summary of said article.textrank
is a summary generated for this project via the textrank algorithm.The data is from Kaggle, and can be found at https://www.kaggle.com/pariza/bbc-news-summary
rouge_n()
is rougeR's primary method for calculating ROUGE-N statistics. It accepts a candidate and reference summary, as well as a value for n.
load("~/GitHub/rougeR/data/data.rda") candidate <- data$summary[1] reference <- data$textrank[1] n <- 2 rouge_n(candidate, reference, n)
As you can see, the rouge_n()
function returns a dataframe with three values: recall
, precision
, and f_measure
. See Lin (2004) for more information about interpreting these values.
For more robust analysis, some researchers may compare a single candidate summary to multiple reference summaries. In rougeR, this can be accomplished with multi_rouge_n()
. multi_rouge_n()
accepts the same values as rouge_n()
, but can accept a character vector of multiple candidate summaries.
rouge_s()
is rougeR's function for calculating ROUGE-S statistics. It accepts a candidate and reference summary, as well as a maximum skip distance (default 1). rouge_s()
also accepts another value: beta
, which is a measure of the importance of precision in relation to recall in calculating the F-measure. The default is 1, implying equal importance.
load("~/GitHub/rougeR/data/data.rda") candidate <- data$summary[2] reference <- data$textrank[2] k <- 1 beta <- 1 rouge_s(candidate, reference, k, beta)
In your research, some analysis may be necessary to determine the ideal values of k and beta. See Lin(2004) for more information on interpreting these values.
Lin, C., 2004. ROUGE: A Package for Automatic Evaluation of Summaries. [online] Barcelona, Spain: Association for Computational Linguistics, pp.74-81. Available at: https://www.aclweb.org/anthology/W04-1013/.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.