Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UCAS-China
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
2023 Competition
Software Tools
UCAS-China
Commits
d9c2b536
Commit
d9c2b536
authored
1 year ago
by
Zhili Wang
Browse files
Options
Downloads
Patches
Plain Diff
update mono
parent
1a533438
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
software2023/mono/desc_pre.json
+2400
-0
2400 additions, 0 deletions
software2023/mono/desc_pre.json
software2023/mono/webui.py
+17
-13
17 additions, 13 deletions
software2023/mono/webui.py
with
2417 additions
and
13 deletions
software2023/mono/desc_pre.json
0 → 100644
+
2400
−
0
View file @
d9c2b536
This diff is collapsed.
Click to expand it.
software2023/mono/web
_
ui.py
→
software2023/mono/webui.py
+
17
−
13
View file @
d9c2b536
import
gradio
as
gr
import
gradio
as
gr
import
json
import
json
import
sys
import
sys
import
os
import
os
from
use_bio_html
import
run
from
use_bio_html
import
run
...
@@ -12,7 +12,7 @@ HTML_BASE = """<div style="padding-left: 5px; padding-right: 0px;">
...
@@ -12,7 +12,7 @@ HTML_BASE = """<div style="padding-left: 5px; padding-right: 0px;">
</style>
</style>
<div style=
"
font-size:20px;display:flex;
"
>
<div style=
"
font-size:20px;display:flex;
"
>
<strong> Name </strong>
<strong> Name
</strong>
<strong style=
"
word-wrap:break-word;padding: 0px 50px 25px 60px;text-align: center;
"
>Definition</strong>
<strong style=
"
word-wrap:break-word;padding: 0px 50px 25px 60px;text-align: center;
"
>Definition</strong>
</div>
</div>
<ol start=
"
1
"
style=
"
color:grey
"
>
<ol start=
"
1
"
style=
"
color:grey
"
>
...
@@ -20,20 +20,18 @@ HTML_BASE = """<div style="padding-left: 5px; padding-right: 0px;">
...
@@ -20,20 +20,18 @@ HTML_BASE = """<div style="padding-left: 5px; padding-right: 0px;">
HTML_TEMPLATE
=
"""
HTML_TEMPLATE
=
"""
<li style=
"
font-size:20px;display:flex;
"
class=
"
textspan svelte-ju12zg hl
"
>
<li style=
"
font-size:20px;display:flex;
"
class=
"
textspan svelte-ju12zg hl
"
>
<a href=
"
http://parts.igem.org/Part:{name}
"
target=
"
_blank
"
><u>{name}</u></a>
<a href=
"
http://parts.igem.org/Part:{name}
"
target=
"
_blank
"
style=
"
width:128px;
"
><u>{name}</u></a>
<div style=
"
word-wrap:break-word;padding: 0px 50px 25px 50px
"
>{definition}</div>
<div style=
"
word-wrap:break-word;padding: 0px 50px 25px 50px
"
>{definition}</div>
</li>
</li>
"""
"""
with
open
(
"
target_words.txt
"
)
as
f
:
with
open
(
"
target_words.txt
"
)
as
f
:
word_list
=
f
.
readlines
()
word_list
=
f
.
readlines
()
with
open
(
"
train
.json
"
)
as
f
:
with
open
(
"
desc_pre
.json
"
)
as
f
:
word_desriptions
=
json
.
load
(
f
)
word_desriptions
=
json
.
load
(
f
)
def
calcolor
(
p
):
def
calcolor
(
p
):
...
@@ -45,14 +43,18 @@ def calcolor(p):
...
@@ -45,14 +43,18 @@ def calcolor(p):
def
predict
(
text
):
def
predict
(
text
):
res_index
,
res_score
,
res_name
=
run
(
text
)
res_index
,
res_score
,
res_name
=
run
(
text
)
html_res
=
(
html_res
=
(
HTML_BASE
HTML_BASE
+
""
.
join
(
+
""
.
join
(
[
[
HTML_TEMPLATE
.
format
(
HTML_TEMPLATE
.
format
(
color
=
calcolor
(
1
-
i
/
len
(
res_index
)),
definition
=
word_desriptions
[
res_index
[
i
]][
"
definitions
"
],
name
=
word_list
[
i
]
color
=
calcolor
(
1
-
i
/
len
(
res_index
)),
definition
=
word_desriptions
[
word_list
[
res_index
[
i
]].
strip
(
"
\n
"
)],
name
=
word_list
[
res_index
[
i
]
],
# .ljust(13,'\n').replace('\n',' ')
)
)
for
i
in
range
(
len
(
res_index
))
for
i
in
range
(
len
(
res_index
))
]
]
...
@@ -62,9 +64,11 @@ def predict(text):
...
@@ -62,9 +64,11 @@ def predict(text):
return
html_res
return
html_res
with
gr
.
Blocks
(
title
=
"
Reverse Dictonary for Biobricks
"
)
as
demo
:
with
gr
.
Blocks
(
title
=
"
Ask NOX
"
)
as
demo
:
gr
.
Markdown
(
"
# Welcome to use Reverse Dictonary for Biobricks
"
)
gr
.
Markdown
(
"
# Welcome to use Ask NOX!
"
)
input
=
gr
.
Textbox
(
label
=
""
,
placeholder
=
"
Please type what you want...
"
)
input
=
gr
.
Textbox
(
label
=
""
,
placeholder
=
"
Please type the description of the biobricks you want...
"
)
greet_btn
=
gr
.
Button
(
"
Look up
"
)
greet_btn
=
gr
.
Button
(
"
Look up
"
)
output
=
gr
.
HTML
()
output
=
gr
.
HTML
()
greet_btn
.
click
(
fn
=
predict
,
inputs
=
input
,
outputs
=
output
,
api_name
=
"
predict
"
)
greet_btn
.
click
(
fn
=
predict
,
inputs
=
input
,
outputs
=
output
,
api_name
=
"
predict
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment