import gradio as gr from main import main import nltk def rexplore_summarizer(corpus): response = main(corpus) return response, response['summary'], response['mindmap'] def clear_everything(text_corpus, raw_data, summary, mindmap): return None, None, None, None theme = gr.themes.Soft( primary_hue="purple", secondary_hue="cyan", neutral_hue="slate", font=[ gr.themes.GoogleFont('Syne'), gr.themes.GoogleFont('Poppins'), gr.themes.GoogleFont('Poppins'), gr.themes.GoogleFont('Poppins') ], ) with gr.Blocks(theme=theme, title="ReXplore Summarizer", fill_height=True) as app: gr.HTML( value ='''
Designed and Developed by Nayan Kasturi
This app uses a hybrid approach to summarize PDF documents based on CPU as well as GPU.
The app uses traditional methodologies such as TextRank, LSA, Luhn algorithms as well as large language model (LLM) to generate summaries as well as mindmaps.
The summarization process can take some time depending on the size of the text corpus and the complexity of the content.
''') with gr.Row(): with gr.Column(): text_corpus = gr.TextArea(label="Text Corpus", placeholder="Paste the text corpus here", lines=5) with gr.Row(): clear_btn = gr.Button(value="Clear", variant='stop') summarize_btn = gr.Button(value="Summarize", variant='primary') raw_data = gr.TextArea(label="Raw Data", placeholder="The generated raw data will be displayed here", lines=7, interactive=False, show_copy_button=True) with gr.Row(): summary = gr.TextArea(label="Summary", placeholder="The generated summary will be displayed here", lines=7, interactive=False, show_copy_button=True) mindmap = gr.TextArea(label="Mindmap", placeholder="The generated mindmap will be displayed here", lines=7, interactive=False, show_copy_button=True) summarize_btn.click( rexplore_summarizer, inputs=[text_corpus], outputs=[raw_data, summary, mindmap], concurrency_limit=1, scroll_to_output=True, show_api=True, api_name="rexplore_summarizer", show_progress="full", ) clear_btn.click(clear_everything, inputs=[text_corpus, raw_data, summary, mindmap], outputs=[text_corpus, raw_data, summary, mindmap], show_api=False) nltk.download('punkt') nltk.download('punkt_tab') app.queue(default_concurrency_limit=1).launch(show_api=True)