File size: 1,261 Bytes
cbc1d23 8ba144e cbc1d23 8ba144e cbc1d23 8ba144e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
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
# file_process:
# in util
# read file code
# file to json_text
# convert:
# in util
# convert code
# json_text to text
# process:
# in util
# text process code
# del stop seg
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)
_,outline_list = outline.passage_outline(matrix,title)
output = util.formate_text(title_dict,outline_list)
return title, output |