File size: 1,382 Bytes
b998a05 |
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 |
from summarization_methods import summary_with_lsa
from summarization_methods import summary_with_text_rank
from summarization_methods import summary_with_text_reduction
from summarization_methods import summary_with_tfidf
import gradio as gr
from enum import Enum
class SummarizationMehods(Enum):
LSA = 0
TextRank = 1
TextReduction = 2
TfIdf = 3
def summary(text , num_sentences=3 , method = SummarizationMehods(0).name):
if method.casefold() == SummarizationMehods(0).name.casefold():
summary = summary_with_lsa(text , num_sentences)
elif method.casefold()==SummarizationMehods(1).name.casefold():
summary = summary_with_text_rank(text , num_sentences )
elif method.casefold() == SummarizationMehods(2).name.casefold():
summary = summary_with_text_reduction(text , num_sentences)
elif method.casefold() == SummarizationMehods(3).name.casefold():
summary = summary_with_tfidf(text , num_sentences)
return summary
demo = gr.Interface(
fn=summary,
inputs=[gr.TextArea() , gr.Slider(minimum=1 , maximum=10 , step=1) ,
gr.Dropdown(choices=[SummarizationMehods(0).name ,SummarizationMehods(1).name ,
SummarizationMehods(2).name , SummarizationMehods(3).name])],
outputs=gr.Text()
)
if __name__ == '__main__':
demo.launch() |