Spaces:
Runtime error
Runtime error
10zinten
commited on
Commit
•
084c06a
1
Parent(s):
ef2d525
format output to html
Browse files- .gitignore +1 -0
- app.py +9 -2
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.ipynb_checkpoints/
|
app.py
CHANGED
@@ -4,8 +4,15 @@ import gradio as gr
|
|
4 |
word_vectors_path = "classical_bo.wordvectors"
|
5 |
wv = KeyedVectors.load(str(word_vectors_path), mmap='r')
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
def find_most_similar(word):
|
8 |
-
|
|
|
9 |
|
10 |
title = "Classical Bo Word2Vec word vectors"
|
11 |
examples = ['སྟོབས་']
|
@@ -13,7 +20,7 @@ examples = ['སྟོབས་']
|
|
13 |
demo = gr.Interface(
|
14 |
fn=find_most_similar,
|
15 |
inputs="text",
|
16 |
-
outputs="
|
17 |
title=title,
|
18 |
examples=examples
|
19 |
).launch()
|
4 |
word_vectors_path = "classical_bo.wordvectors"
|
5 |
wv = KeyedVectors.load(str(word_vectors_path), mmap='r')
|
6 |
|
7 |
+
def format_to_html(sim_ouput):
|
8 |
+
html = ""
|
9 |
+
for word, sim in sim_output:
|
10 |
+
html += f"<div>{word}: {round(sim, 4)}</div>"
|
11 |
+
return "<div>" + html + "</div>"
|
12 |
+
|
13 |
def find_most_similar(word):
|
14 |
+
sim_output = wv.most_similar(word)
|
15 |
+
return format_to_html(sim_ouput)
|
16 |
|
17 |
title = "Classical Bo Word2Vec word vectors"
|
18 |
examples = ['སྟོབས་']
|
20 |
demo = gr.Interface(
|
21 |
fn=find_most_similar,
|
22 |
inputs="text",
|
23 |
+
outputs="html",
|
24 |
title=title,
|
25 |
examples=examples
|
26 |
).launch()
|