Closed TysonYu closed 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
Thank you for sharing this code. What's the difference between function calrouge(hyps, refer) and rouge_eval(hyps, refer)?
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!
Thanks
thank you!
我想尝试你的这个方法在其他数据集上,需要手动生成extractive的label,能分享一下ORACLE算法吗?万分感谢!