dqwang122 / HeterSumGraph

Code for ACL2020 paper "Heterogeneous Graph Neural Networks for Extractive Document Summarization"
244 stars 52 forks source link

你好,想问一下你是如何实现ORACLE算法从abstractive summary得到extractive的label的? #7

Closed TysonYu closed 4 years ago

TysonYu commented 4 years ago

我想尝试你的这个方法在其他数据集上,需要手动生成extractive的label,能分享一下ORACLE算法吗?万分感谢!

dqwang122 commented 4 years ago

我们的做法是参考了 SummaRuNNer: A Recurrent Neural Network based Sequence Model for Extractive Summarization of Documents 这篇论文的贪婪式抽取。下面是一个简单的参考:

You can refer to the greedy algorithm in SummaRuNNer: A Recurrent Neural Network based Sequence Model for Extractive Summarization of Documents. Here is a simple way to do it:

def calLabel(article, abstract):
    hyps_list = article
    refer = abstract
    scores = []
    for hyps in hyps_list:
        mean_score = rouge_eval(hyps, refer)
        scores.append(mean_score)

    selected = [int(np.argmax(scores))]
    selected_sent_cnt = 1

    best_rouge = np.max(scores)
    while selected_sent_cnt < len(hyps_list):
        cur_max_rouge = 0.0
        cur_max_idx = -1
        for i in range(len(hyps_list)):
            if i not in selected:
                temp = copy.deepcopy(selected)
                temp.append(i)
                hyps = "\n".join([hyps_list[idx] for idx in np.sort(temp)])
                cur_rouge = rouge_eval(hyps, refer)
                if cur_rouge > cur_max_rouge:
                    cur_max_rouge = cur_rouge
                    cur_max_idx = i
        if cur_max_rouge != 0.0 and cur_max_rouge >= best_rouge:
            selected.append(cur_max_idx)
            selected_sent_cnt += 1
            best_rouge = cur_max_rouge
        else:
            break
    # print(selected, best_rouge)
    return selected
yeliu918 commented 4 years ago

Thank you for sharing this code. What's the difference between function calrouge(hyps, refer) and rouge_eval(hyps, refer)?

dqwang122 commented 4 years ago

Thank you for sharing this code. What's the difference between function calrouge(hyps, refer) and rouge_eval(hyps, refer)?

There is no big difference between these two functions. I have changed them to the same one. Thanks!

yeliu918 commented 4 years ago

Thanks

TysonYu commented 4 years ago

thank you!