|
|
|
import gradio as gr |
|
import spacy |
|
import os |
|
|
|
|
|
os.system("python -m spacy download en_core_web_sm") |
|
|
|
|
|
nlp = spacy.load("en_core_web_sm") |
|
|
|
def identify_nouns_verbs(text): |
|
|
|
doc = nlp(text) |
|
|
|
|
|
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} |
|
|
|
|
|
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() |
|
|
|
|