Spaces:
Sleeping
Sleeping
File size: 2,934 Bytes
0d3b770 09b648b a14002e 0d3b770 e9b7721 0d3b770 a14002e c63e932 31ba554 a14002e a463b89 a14002e a463b89 a14002e 0d3b770 a14002e 0d3b770 a14002e 0d3b770 a14002e 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
from textblob import TextBlob
import gradio as gr
import os
os.system("python -m textblob.download_corpora")
string_json={
'control':'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN',
}
cont_list=list(string_json['control'])
def get_nouns(text):
json_object={}
sen_list=[]
blob = TextBlob(text)
for sentence in blob.sentences:
print(sentence)
sen_list.append(str(sentence))
key_cnt=len(sen_list)
cnt=0
go=True
a="Z"
if go:
for ea in range(10):
if go:
for b in range(50):
if go:
for c in range(50):
if go:
for d in range(50):
if go:
#for i,ea in enumerate(key_list):
#json_object[sen_list[cnt]]=f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}'
f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}'=json_object[sen_list[cnt]]
if json_object[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']=='ZNNN':
#if json_object[sen_list[cnt]]=='ZNNN':
#print ("Y")
a="Y"
b=0
c=0
d=0
if json_object[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']=='YNNN':
#print("X")
a="X"
b=0
c=0
d=0
#print(cnt)
if cnt == key_cnt-1:
print('done')
go=False
print(list(json_object.keys())[-1])
else:
cnt+=1
#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', ...])
return json_object
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.JSON(label="Nouns")
btn.click(get_nouns,inp,nouns)
app.launch()
|