Ejemplo n.º 1
0
def _rouge(ref_file, summarization_file, subword_option=None):
    references = []
    with codecs.getreader("utf-8")(tf.gfile.GFile(ref_file, "rb")) as f:
        for line in f:
            references.append(_clean(line, subword_option))

    hypotheses = []
    with codecs.getreader("utf-8")(tf.gfile.GFile(summarization_file,
                                                  "rb")) as f:
        for line in f:
            hypotheses.append(_clean(line, subword_option=None))

    rouge_score_map = rouge.rouge(hypotheses, references)
    return 100 * rouge_score_map["rouge_l/f_score"]
Ejemplo n.º 2
0
def _rouge(ref_file, summarization_file, bpe_delimiter=None):
    """Compute ROUGE scores and handling BPE."""

    references = []
    with codecs.getreader("utf-8")(tf.gfile.GFile(ref_file, "rb")) as fh:
        for line in fh:
            references.append(_clean(line, bpe_delimiter))

    hypotheses = []
    with codecs.getreader("utf-8")(tf.gfile.GFile(summarization_file,
                                                  "rb")) as fh:
        for line in fh:
            hypotheses.append(_clean(line, bpe_delimiter))

    rouge_score_map = rouge.rouge(hypotheses, references)
    return 100 * rouge_score_map["rouge_l/f_score"]