# app.py import gradio as gr import spacy from transformers import pipeline # Load the spaCy model for POS tagging nlp = spacy.load("en_core_web_sm") def identify_nouns_verbs(text): # Process the text with spaCy doc = nlp(text) # Extract nouns and verbs nouns = [token.text for token in doc if token.pos_ == "NOUN"] verbs = [token.text for token in doc if token.pos_ == "VERB"] return {"Nouns": nouns, "Verbs": verbs} # Create the Gradio interface iface = gr.Interface( fn=identify_nouns_verbs, inputs=gr.inputs.Textbox(lines=10, placeholder="Enter your text here..."), outputs=gr.outputs.JSON(), title="Noun and Verb Identifier", description="Enter a document or text to identify the nouns and verbs." ) if __name__ == "__main__": iface.launch()