Spaces:
Runtime error
Runtime error
File size: 720 Bytes
0d3b770 |
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 |
from textblob import TextBlob
import gradio as gr
def get_nouns(text):
blob = TextBlob(text)
print(blob.tags) # [('The', 'DT'), ('titular', 'JJ'),
# ('threat', 'NN'), ('of', 'IN'), ...]
print(blob.parse())
print(blob.noun_phrases) # WordList(['titular threat', 'blob',
# 'ultimate movie monster',
# 'amoeba-like mass', ...])
for sentence in blob.sentences:
print(sentence)
with gr.Blocks() as app:
with gr.Row():
with gr.Column(scale=3):
inp = gr.Textbox(lines=10)
btn = gr.Button()
with gr.Column(scale=1):
nouns=gr.Textbox(label="Nouns")
btn.click(get_nouns,inp,nouns)
app.launch()
|