Spaces:
Runtime error
Runtime error
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="dark-peach", | |
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), | |
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 v.1.0.0", | |
description=""" | |
""" | |
) | |
iface.launch() |