File size: 810 Bytes
522d644
0b01c5c
522d644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
30
31
# 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()