janus.metrics.rouge_score#

Functions#

rouge(target, reference[, granularity, n_gram, score_type])

Calculate the ROUGE Score.

Module Contents#

janus.metrics.rouge_score.rouge(target, reference, granularity='n', n_gram=2, score_type='f', **kwargs)#

Calculate the ROUGE Score.

Parameters:
  • target (str) – The target text.

  • reference (str) – The reference text.

  • granularity (typing_extensions.Annotated[str, typer.Option('--granularity', '-g', help='The granularity of the ROUGE score. `n` refers to ROUGE-N, `l` refers to ROUGE-L, and `w` refers to ROUGE-W.', click_type=click.Choice(['n', 'l', 'w']))]) – The granularity of the ROUGE score. n refers to ROUGE-N, l refers to ROUGE-L, and w refers to ROUGE-W.

  • n_gram (typing_extensions.Annotated[int, typer.Option('--n-gram', '-n', help='The n-gram overlap calculated for ROUGE-N. Can be an integer.')]) – The n-gram overlap calculated for ROUGE-N. Can be an integer.

  • score_type (typing_extensions.Annotated[str, typer.Option('--score', '-s', help='Whether to use the F-score, precision, or recall. For example, `f` refers to the F-score, `p` refers to precision, and `r` refers to recall.', click_type=click.Choice(['f', 'p', 'r']))]) – Whether to use the F-score, precision, or recall. For example, f refers to the F-score, p refers to precision, and r refers to recall.

Returns:

The ROUGE score.

Return type:

float