File size: 1,042 Bytes
6bfccc1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02d932f
6bfccc1
 
f04f1cd
6bfccc1
 
 
f04f1cd
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
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