Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from gensim.models import FastText | |
| # Load your trained FastText model | |
| model_path = "fasttext_cs.model" | |
| ft_model = FastText.load(model_path) | |
| def get_nearest(word): | |
| if word in ft_model.wv: | |
| return ft_model.wv.most_similar(word, topn=10) | |
| else: | |
| return f"Word '{word}' not found in vocabulary." | |
| # Define a Gradio interface | |
| iface = gr.Interface( | |
| fn=get_nearest, | |
| inputs="text", | |
| outputs="json", | |
| title="FastText Nearest Neighbors", | |
| description="Enter a word from the cs_query vocabulary to see its top 10 similar words." | |
| ) | |
| iface.launch() | |