10zinten
format output to html
084c06a
raw history blame
No virus
632 Bytes
from gensim.models import KeyedVectors
import gradio as gr
word_vectors_path = "classical_bo.wordvectors"
wv = KeyedVectors.load(str(word_vectors_path), mmap='r')
def format_to_html(sim_ouput):
html = ""
for word, sim in sim_output:
html += f"<div>{word}: {round(sim, 4)}</div>"
return "<div>" + html + "</div>"
def find_most_similar(word):
sim_output = wv.most_similar(word)
return format_to_html(sim_ouput)
title = "Classical Bo Word2Vec word vectors"
examples = ['སྟོབས་']
demo = gr.Interface(
fn=find_most_similar,
inputs="text",
outputs="html",
title=title,
examples=examples
).launch()