TSA / run.py
QINGCHE's picture
unable baidu
02d932f
raw
history blame
1.04 kB
import util
import abstract
import classification
import inference
import outline
from inference import BertClassificationModel
# input:file/text,topic_num,max_length,output_choice
# output:file/text/topic_sentence
def texClear(article):
sentencesCleared = [util.clean_text(sentence) for sentence in article]
sentencesCleared = [string for string in sentencesCleared if string != '' ]
# print(sentencesCleared)
return sentencesCleared
def textToAb(sentences, article, topic_num, max_length):
central_sentences = abstract.abstruct_main(sentences, topic_num)
groups = classification.classify_by_topic(article, central_sentences)
groups = util.article_to_group(groups, central_sentences)
title_dict,title = util.generation(groups, max_length)
# ans:
# {Ai_abstruct:(main_sentence,paragraph)}
# print(title)
matrix = inference.inference_matrix(title)
outl,outline_list = outline.passage_outline(matrix,title)
output = util.formate_text(title_dict,outline_list)
return outl, output