File size: 656 Bytes
fefbde9 |
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 |
import gradio as gr
from nltk.corpus import wordnet as wn
# Function to get the definition of the first synset for a given word
def get_synset_definition(word):
synsets = wn.synsets(word)
if synsets:
first_synset = synsets[0]
return first_synset.definition()
else:
return "No synsets found for the given word."
# Gradio Interface
iface = gr.Interface(
fn=get_synset_definition,
inputs=gr.Textbox(),
outputs=gr.Textbox(),
live=True,
title="WordNet Synset Definition",
description="Enter a word to get the definition of its first WordNet synset.",
)
# Launch the Gradio interface
iface.launch()
|