class_docstr: ROUGE Metrics.
  
  ROUGE stands for Recall-Oriented Understudy for Gisting Evaluation. It
  includes measures to automatically determine the quality of a summary by
  comparing it to other (ideal) reference / target summaries.
  
  ROUGE was originally introduced in the paper:
  
  Lin, Chin-Yew. ROUGE: a Package for Automatic Evaluation of Summaries. In
  Proceedings of the Workshop on Text Summarization Branches Out (WAS 2004),
  Barcelona, Spain, July 25 - 26, 2004.
  
  This implementation supports Rouge-N where N is an int in [1, 9], RougeL, and
  RougeLsum. Note, to calculate multiple ROUGE Metrics, you will need to call
  this metric multiple times.
  
  For this implementation, a Label is expected to be a list of texts containing
  the target summaries. A Prediction is expected to be text containing the
  predicted text.
  
  In the ROUGE paper, two flavors of ROUGE are described:
  
  1. sentence-level: Compute longest common subsequence (LCS) between two pieces
  of text. Newlines are ignored. This is called 'rougeL' in this package.
  2. summary-level: Newlines in the text are interpreted as sentence boundaries,
  and the LCS is computed between each pair of reference and candidate
  sentences, and the union-LCS is computed. This is called
  'rougeLsum' in this package. This is the ROUGE-L reported in *[Get To The
  Point: Summarization with Pointer-Generator Networks]
  (https://arxiv.org/abs/1704.04368)*, for example. If your
  references/candidates do not have newline delimiters, you can use the
  split_summaries argument.
  
  This is a wrapper of the pure python implementation of ROUGE found here:
  https://pypi.org/project/rouge-score/
  
  To implement this metric, see the example below:
  
  eval_config = tfma.EvalConfig(
      metrics_specs=[
          tfma.MetricsSpec(metrics=[
              tfma.MetricConfig(
                  class_name='Rouge',
                  config='"rouge_type":"rouge1"'
          ]),
          tfma.MetricsSpec(metrics=[
              tfma.MetricConfig(
                  class_name='Rouge',
                  config='"rouge_type":"rouge2"'
          ]),
          tfma.MetricsSpec(metrics=[
              tfma.MetricConfig(
                  class_name='Rouge',
                  config='"rouge_type":"rougeL"'
          ]),
          tfma.MetricsSpec(metrics=[
              tfma.MetricConfig(
                  class_name='Rouge',
                  config='"rouge_type":"rougeLsum"'
          ]),
          ...
      ],
      ...
  )
  
  evaluator = tfx.borg.components.Evaluator(
    examples=example_gen.outputs['examples'],
    model=trainer.outputs['model'],
    eval_config=eval_config)
class_docstr_tok: ["ROUGE","Metrics",".","ROUGE","stands","for","Recall-Oriented","Understudy","for","Gisting","Evaluation",".","It","includes","measures","to","automatically","determine","the","quality","of","a","summary","by","comparing","it","to","other","(","ideal",")","reference","\/","target","summaries",".","ROUGE","was","originally","introduced","in","the","paper",":","Lin",",","Chin-Yew",".","ROUGE",":","a","Package","for","Automatic","Evaluation","of","Summaries",".","In","Proceedings","of","the","Workshop","on","Text","Summarization","Branches","Out","(","WAS","2004",")",",","Barcelona",",","Spain",",","July","25","-","26",",","2004",".","This","implementation","supports","Rouge-N","where","N","is","an","int","in","[","1",",","9","]",",","RougeL",",","and","RougeLsum",".","Note",",","to","calculate","multiple","ROUGE","Metrics",",","you","will","need","to","call","this","metric","multiple","times",".","For","this","implementation",",","a","Label","is","expected","to","be","a","list","of","texts","containing","the","target","summaries",".","A","Prediction","is","expected","to","be","text","containing","the","predicted","text",".","In","the","ROUGE","paper",",","two","flavors","of","ROUGE","are","described",":","1.","sentence-level",":","Compute","longest","common","subsequence","(","LCS",")","between","two","pieces","of","text",".","Newlines","are","ignored",".","This","is","called","'rougeL","'","in","this","package",".","2.","summary-level",":","Newlines","in","the","text","are","interpreted","as","sentence","boundaries",",","and","the","LCS","is","computed","between","each","pair","of","reference","and","candidate","sentences",",","and","the","union-LCS","is","computed",".","This","is","called","'rougeLsum","'","in","this","package",".","This","is","the","ROUGE-L","reported","in","*","[","Get","To","The","Point",":","Summarization","with","Pointer-Generator","Networks","]","(","https",":","\/\/arxiv.org\/abs\/1704.04368",")","*",",","for","example",".","If","your","references\/candidates","do","not","have","newline","delimiters",",","you","can","use","the","split_summaries","argument",".","This","is","a","wrapper","of","the","pure","python","implementation","of","ROUGE","found","here",":","https",":","\/\/pypi.org\/project\/rouge-score\/","To","implement","this","metric",",","see","the","example","below",":","eval_config","=","tfma.EvalConfig","(","metrics_specs=","[","tfma.MetricsSpec","(","metrics=","[","tfma.MetricConfig","(","class_name='Rouge","'",",","config=","'","''","rouge_type","''",":","''","rouge1","''","'","]",")",",","tfma.MetricsSpec","(","metrics=","[","tfma.MetricConfig","(","class_name='Rouge","'",",","config=","'","''","rouge_type","''",":","''","rouge2","''","'","]",")",",","tfma.MetricsSpec","(","metrics=","[","tfma.MetricConfig","(","class_name='Rouge","'",",","config=","'","''","rouge_type","''",":","''","rougeL","''","'","]",")",",","tfma.MetricsSpec","(","metrics=","[","tfma.MetricConfig","(","class_name='Rouge","'",",","config=","'","''","rouge_type","''",":","''","rougeLsum","''","'","]",")",",","...","]",",","...",")","evaluator","=","tfx.borg.components.Evaluator","(","examples=example_gen.outputs","[","'examples","'","]",",","model=trainer.outputs","[","'model","'","]",",","eval_config=eval_config",")"]
docstr: Initializes ROUGE Metrics.
docstr_tok: ["Initializes","ROUGE","Metrics","."]
code: def __init__(
      self,
      rouge_type: str,
      name: Optional[str] = None,
      use_stemmer: Optional[bool] = False,
      split_summaries: Optional[bool] = False,
      tokenizer: Optional[tokenizers.Tokenizer] = None,
  ):
      """Initializes ROUGE Metrics."""
  
      super().__init__(
          metric_util.merge_per_key_computations(_rouge),
          rouge_type=rouge_type,
          name=name or rouge_type,
          use_stemmer=use_stemmer,
          split_summaries=split_summaries,
          tokenizer=tokenizer,
      )
  
imports: import dataclasses
  from typing import Dict, Iterable, Optional
  from absl import logging
  import apache_beam
  import nltk
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.proto import config_pb2
  from rouge_score import rouge_scorer
  from rouge_score import scoring
  from rouge_score import tokenizers
label_desc: Use image node_id 1 to create a new Rouge object from inherited base classes: metric_types with example: obj = Rouge(rouge_type, name, use_stemmer, split_summaries, tokenizer)