13Aluminium commited on
Commit
2bd2d16
·
verified ·
1 Parent(s): 5d5dbe9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gensim.models import FastText
3
+
4
+ # Load your trained FastText model
5
+ model_path = "fasttext_cs.model"
6
+ ft_model = FastText.load(model_path)
7
+
8
+ def get_nearest(word):
9
+ if word in ft_model.wv:
10
+ return ft_model.wv.most_similar(word, topn=10)
11
+ else:
12
+ return f"Word '{word}' not found in vocabulary."
13
+
14
+ # Define a Gradio interface
15
+ iface = gr.Interface(
16
+ fn=get_nearest,
17
+ inputs="text",
18
+ outputs="json",
19
+ title="FastText Nearest Neighbors",
20
+ description="Enter a word from the cs_query vocabulary to see its top 10 similar words."
21
+ )
22
+
23
+ iface.launch()