File size: 632 Bytes
ef2d525
08aa470
 
ef2d525
 
08aa470
084c06a
 
 
 
 
 
ef2d525
084c06a
 
ef2d525
 
 
 
 
 
 
084c06a
ef2d525
 
 
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
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()