vec = Vectoriser(docs, base=self.base_length) rl_agent = RLAgent(vec, summaries, strict_para=self.rl_strict, train_round=self.train_episode) summary = rl_agent(rewards) return summary if __name__ == '__main__': # read source documents reader = CorpusReader('data/topic_1') source_docs = reader() # generate summaries, with summary max length 100 tokens supert = Supert(source_docs) rl_summarizer = RLSummarizer(reward_func=supert) summary = rl_summarizer.summarize(source_docs, summ_max_len=100) print('\n=====Generated Summary=====') print(summary) # (Optional) Evaluate the quality of the summary using ROUGE metrics if os.path.isdir('./rouge/ROUGE-RELEASE-1.5.5'): refs = reader.readReferences( ) # make sure you have put the references in data/topic_1/references avg_rouge_score = {} for ref in refs: rouge_scores = evaluate_summary_rouge(summary, ref) add_result(avg_rouge_score, rouge_scores) print('\n=====ROUGE scores against {} references====='.format( len(refs)))