Spaces:
Runtime error
Runtime error
File size: 3,186 Bytes
dee848c b796027 dee848c b796027 dee848c |
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
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() |