Spaces:
Runtime error
Runtime error
feat: Add configured options and base layout
Browse files
app.py
CHANGED
@@ -1,7 +1,95 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=parse_patent_source, inputs="text", outputs="text")
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
from util import summarizer, parser
|
4 |
|
5 |
+
def patent_summarizer(patent_information, summaries_generated, min_char_abs, min_char_bg, min_char_claims):
|
6 |
+
|
7 |
+
# TODO: add checker if valid patent info, return None if invalid
|
8 |
+
# TODO: add scraper to get document
|
9 |
+
|
10 |
+
# TODO: add parser to get the following info from the base document:
|
11 |
+
abstract, background, claims = None, None, None
|
12 |
+
|
13 |
+
summaries = list()
|
14 |
+
if "Abstract" in summaries_generated:
|
15 |
+
abstract_summary = summarizer.generate_abs_summary(abstract, min_char_abs)
|
16 |
+
summaries.append(abstract_summary)
|
17 |
+
else:
|
18 |
+
summaries.append(None)
|
19 |
+
|
20 |
+
if "Background" in summaries_generated:
|
21 |
+
background_summary = summarizer.generate_bg_summary(background, min_char_bg)
|
22 |
+
summaries.append(background_summary)
|
23 |
+
else:
|
24 |
+
summaries.append(None)
|
25 |
+
|
26 |
+
if "Claims" in summaries_generated:
|
27 |
+
claims_summary = summarizer.generate_claims_summary(claims, min_char_claims)
|
28 |
+
summaries.append(claims_summary)
|
29 |
+
else:
|
30 |
+
summaries.append(None)
|
31 |
+
|
32 |
+
return summaries
|
33 |
+
|
34 |
+
summary_options = ["Abstract", "Background", "Claims"]
|
35 |
+
iface = gr.Interface(
|
36 |
+
patent_summarizer,
|
37 |
+
theme="dark-peach",
|
38 |
+
examples=[
|
39 |
+
[
|
40 |
+
"US9820315B2",
|
41 |
+
summary_options,
|
42 |
+
50,
|
43 |
+
250,
|
44 |
+
100
|
45 |
+
],
|
46 |
+
[
|
47 |
+
"https://patents.google.com/patent/US9820315B2",
|
48 |
+
summary_options,
|
49 |
+
50,
|
50 |
+
250,
|
51 |
+
100
|
52 |
+
],
|
53 |
+
[
|
54 |
+
"https://patents.google.com/patent/US10263802B2/en?q=smart+user+interface&oq=smart+user+interface",
|
55 |
+
summary_options[:-1],
|
56 |
+
75,
|
57 |
+
200,
|
58 |
+
125
|
59 |
+
|
60 |
+
]
|
61 |
+
],
|
62 |
+
inputs=[
|
63 |
+
gr.inputs.Textbox(label="Patent Information",
|
64 |
+
placeholder="US9820315B2 or https://patents.google.com/patent/US9820315B2 ...",
|
65 |
+
lines=1),
|
66 |
+
# gr.inputs.Radio(["Link", "Patent Code"]), # Can be figured out automatically via parsing
|
67 |
+
# gr.inputs.Dropdown(["model type 1", "model type 2", "model type 3"]), # Change model type
|
68 |
+
gr.inputs.CheckboxGroup(summary_options, default=summary_options),
|
69 |
+
gr.inputs.Slider(minimum=50,
|
70 |
+
maximum=500,
|
71 |
+
step=1,
|
72 |
+
default=75,
|
73 |
+
label="Minimum Characters (Abstract Summary)"),
|
74 |
+
gr.inputs.Slider(minimum=50,
|
75 |
+
maximum=500,
|
76 |
+
step=1,
|
77 |
+
default=200,
|
78 |
+
label="Minimum Characters (Background Summary)"),
|
79 |
+
gr.inputs.Slider(minimum=50,
|
80 |
+
maximum=500,
|
81 |
+
step=1,
|
82 |
+
default=100,
|
83 |
+
label="Minimum Characters (Per Claims Summary)")
|
84 |
+
],
|
85 |
+
outputs=[
|
86 |
+
gr.outputs.Textbox(label="Abstract Summary"),
|
87 |
+
gr.outputs.Textbox(label="Background Summary"),
|
88 |
+
gr.outputs.Textbox(label="Claims Summary")
|
89 |
+
],
|
90 |
+
title="Patent Summarizer v.1.0.0",
|
91 |
+
description="""
|
92 |
+
"""
|
93 |
+
)
|
94 |
|
|
|
95 |
iface.launch()
|