import gradio as gr import pandas as pd from util import summarizer, parser def patent_summarizer(patent_information, summaries_generated, min_char_abs, min_char_bg, min_char_claims): # TODO: add checker if valid patent info, return None if invalid # TODO: add scraper to get document # TODO: add parser to get the following info from the base document: abstract, background, claims = None, None, None summaries = list() if "Abstract" in summaries_generated: abstract_summary = summarizer.generate_abs_summary(abstract, min_char_abs) summaries.append(abstract_summary) else: summaries.append(None) if "Background" in summaries_generated: background_summary = summarizer.generate_bg_summary(background, min_char_bg) summaries.append(background_summary) else: summaries.append(None) if "Claims" in summaries_generated: claims_summary = summarizer.generate_claims_summary(claims, min_char_claims) summaries.append(claims_summary) else: summaries.append(None) return summaries summary_options = ["Abstract", "Background", "Claims"] iface = gr.Interface( patent_summarizer, theme="huggingface", examples=[ [ "US9820315B2", summary_options, 50, 250, 100 ], [ "https://patents.google.com/patent/US9820315B2", summary_options, 50, 250, 100 ], [ "https://patents.google.com/patent/US10263802B2/en?q=smart+user+interface&oq=smart+user+interface", summary_options[:-1], 75, 200, 125 ] ], inputs=[ gr.inputs.Textbox(label="Patent Information", placeholder="US9820315B2 or https://patents.google.com/patent/US9820315B2 ...", lines=1), # gr.inputs.Radio(["Link", "Patent Code"]), # Can be figured out automatically via parsing # gr.inputs.Dropdown(["model type 1", "model type 2", "model type 3"]), # Change model type gr.inputs.CheckboxGroup(summary_options, default=summary_options, label="Summaries to Generate"), gr.inputs.Slider(minimum=50, maximum=500, step=1, default=75, label="Minimum Characters (Abstract Summary)"), gr.inputs.Slider(minimum=50, maximum=500, step=1, default=200, label="Minimum Characters (Background Summary)"), gr.inputs.Slider(minimum=50, maximum=500, step=1, default=100, label="Minimum Characters (Per Claims Summary)") ], outputs=[ gr.outputs.Textbox(label="Abstract Summary"), gr.outputs.Textbox(label="Background Summary"), gr.outputs.Textbox(label="Claims Summary") ], title="Patent Summarizer 📖", description=""" v.1.0.0 Reading through patent documents is oftentimes a long and tedious task. There are cases wherein one has to manually go through several pages in order to determine if the patent is relevant to the prior art search. This application is meant to automate the initial phase of going through patents so that the potential inventor or researcher may lessen the time spent trying to filter documents. The Patent Summarizer: ✏️ Provides an interface for user input 📂 Retrieves and parses the document based on the given patent information 📑 Returns summaries for the abstract, background, and/or claims. """ ) iface.launch()