continue if not (compression > 0 and compression < 100): print("Out of bounds, try again") num_of_sentences = int((compression/100) * article_dict["LENGTH"]) if num_of_sentences == 0: print("The desired compression rate for this article resulted in a zero sentence summary. Please try" " again with a higher rate of compression") exit() edmundson = Edmundson(article_dict) rhetoric = ExtractedArticle(article_dict) textrank = TextRank(article_dict["BODY"]) master_scores = list(map(sum, zip(edmundson.get_sent_scores(custom_settings),rhetoric.get_sent_scores(custom_settings),textrank.get_sent_scores()))) preliminary_indices = sorted(range(len(master_scores)), key=lambda i: master_scores[i])[-(num_of_sentences):] master_indices = sorted(preliminary_indices) print("Display Summary: \n") for index in master_indices: print(article_dict["BODY"][index]) summary += article_dict["BODY"][index] summary = summary + "\n\nThis summary was generated using: " + active_pickle_file + "\n" + "Source shrunk from " + str(article_dict['LENGTH']) + ' sentences to ' + str(num_of_sentences) + " sentences" + " (" + str(compression) + "%)" os.chdir(Summarypath) summary_file = open(article_dict["FILE"][:-4] + "_summary.txt", 'w') # used to be article_dict["FILE"][:-4] summary_file.write(summary)