rouge_scorer.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:wip-constrained-extractor 作者: brain-research 项目源码 文件源码
def get_rouge_recall_suff_stats(self, pred_counts, gold_counts):
    """Get overlapping predicted counts and gold counts for pair of bags."""
    # Map words to their stems.
    pred_stems = tf.transpose(
        tf.sparse_tensor_dense_matmul(
            self.stem_projector_stopworded,
            pred_counts,
            adjoint_a=True,
            adjoint_b=True))
    # <UNK> tokens count as always missing from predicted counts but not
    # from gold counts to avoid overly optimistic evaluation.
    gold_stems = tf.transpose(
        tf.sparse_tensor_dense_matmul(
            self.stem_projector_stopworded_keep_unk,
            gold_counts,
            adjoint_a=True,
            adjoint_b=True))

    # Only count max of 1 point for each overlapping word type
    pred_stems = tf.minimum(1.0, pred_stems)
    gold_stems = tf.minimum(1.0, gold_stems)

    overlaps = tf.reduce_sum(tf.minimum(pred_stems, gold_stems), 1)

    gold_counts = tf.reduce_sum(gold_stems, 1)

    return overlaps, gold_counts
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号