File size: 1,373 Bytes
572f4d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 gradio as gr
import 期刊论文投稿推荐系统
textbox_keyword_inputs = gr.inputs.Textbox(lines=6, placeholder='关键词', default='', label=None, optional=False)
textbox_abstract = gr.inputs.Textbox(lines=1, placeholder='请输入文章摘要', default='', label='摘要', optional=False)


def greet(textbox_keyword_inputs, history=[]):
    outputs = 期刊论文投稿推荐系统.extract_tags(textbox_keyword_inputs)
    label = outputs[0]
    values_1 = outputs[1]
    history.append(textbox_keyword_inputs)
    print([(f"{history[len(history)-1]}", f"{label[0]}")])
    print('----------------------------------')
    print(textbox_keyword_inputs)
    # return [(f"{history[0]}",f"{gr.HTML('根据您的论文所推荐的期刊.html')}")], history
    return [(f"{history[len(history)-1][:50]+'.....'}", f"{label[0]+'综合影响因子:'+str(values_1[0])}")], history


with gr.Blocks() as Interface:
    #   实例化一个机器人聊天组件
    chatbot = gr.Chatbot()
    #   状态码
    state = gr.State([])
    #   水平居中排列
    with gr.Row():
        #   实例化输入文本框
        txt = gr.Textbox(show_label=False, placeholder="请输入文章摘要").style(container=False)
    #   提交文本框后执行分析并输出
    txt.submit(greet, [txt, state], [chatbot, state])
if __name__ == "__main__":
    Interface.launch()