import gradio from kbert_topics import extract_topics from mapping import get_mapping from topics_extraction import classify from PyDictionary import PyDictionary dictionary=PyDictionary() def get_output(event_info): if len(event_info.split(' '))>=20: topic_name, distance_name,topic_name_dep, distance_name_dep, topic_name_other, distance_name_other = get_mapping(event_info) work_list = extract_topics(event_info) work_list = [i for i in work_list if bool(dictionary.meaning(i))] return topic_name+ ' '+str(distance_name), str(topic_name_dep) + ' '+str(distance_name_dep),str(topic_name_other) + ' '+str(distance_name_other), str(work_list),classify(event_info) else: return 'Event discription should have >= 20 words', None, None, None,None with gradio.Blocks(theme = 'gradio/monochrome', title = 'Keyword clustering Demo') as keyword_cluster_demo: gradio.Markdown( "

Interface for checking results of keyword generation and sector/other industries mapping

" ) gradio.HTML( """
Enter event discription
Note: Minimum 20 words
""" ) gradio.HTML( """
Time taken: 2 min
""" ) with gradio.Row(scale = 2): with gradio.Column(scale=1): event_info = gradio.Textbox(label='enter event discription') button = gradio.Button("Submit") output_sec = gradio.outputs.Textbox(label="Mapped sector and score") output_dep = gradio.outputs.Textbox(label="Mapped industry and score") output_other= gradio.outputs.Textbox(label="Mapped other departments/categories") with gradio.Row(): output_keybert = gradio.outputs.Textbox(label="Identified keywords (1 word)") output_tags_identified = gradio.outputs.Textbox(label="Identified Tags") button.click(get_output, [event_info], outputs=[output_sec, output_dep, output_other, output_keybert, output_tags_identified]) #keyword_cluster_demo.queue().launch(share=True,debug =True, show_error =True) keyword_cluster_demo.queue().launch()