Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,17 +2,57 @@ from textblob import TextBlob
|
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
| 4 |
os.system("python -m textblob.download_corpora")
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
def get_nouns(text):
|
| 7 |
blob = TextBlob(text)
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# ('threat', 'NN'), ('of', 'IN'), ...]
|
| 10 |
-
print(blob.parse())
|
| 11 |
-
print(blob.noun_phrases) # WordList(['titular threat', 'blob',
|
| 12 |
# 'ultimate movie monster',
|
| 13 |
# 'amoeba-like mass', ...])
|
| 14 |
-
|
| 15 |
-
print(sentence)
|
| 16 |
|
| 17 |
|
| 18 |
with gr.Blocks() as app:
|
|
@@ -21,7 +61,7 @@ with gr.Blocks() as app:
|
|
| 21 |
inp = gr.Textbox(lines=10)
|
| 22 |
btn = gr.Button()
|
| 23 |
with gr.Column(scale=1):
|
| 24 |
-
nouns=gr.
|
| 25 |
btn.click(get_nouns,inp,nouns)
|
| 26 |
app.launch()
|
| 27 |
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
| 4 |
os.system("python -m textblob.download_corpora")
|
| 5 |
+
string_json={
|
| 6 |
+
'control':'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN',
|
| 7 |
+
}
|
| 8 |
+
cont_list=list(string_json['control'])
|
| 9 |
+
json_object={}
|
| 10 |
def get_nouns(text):
|
| 11 |
blob = TextBlob(text)
|
| 12 |
+
for sentence in blob.sentences:
|
| 13 |
+
print(sentence)
|
| 14 |
+
sen_list.append(sentence)
|
| 15 |
+
cnt=0
|
| 16 |
+
go=True
|
| 17 |
+
a="Z"
|
| 18 |
+
if go:
|
| 19 |
+
for ea in range(10):
|
| 20 |
+
if go:
|
| 21 |
+
for b in range(50):
|
| 22 |
+
if go:
|
| 23 |
+
for c in range(50):
|
| 24 |
+
if go:
|
| 25 |
+
for d in range(50):
|
| 26 |
+
if go:
|
| 27 |
+
#for i,ea in enumerate(key_list):
|
| 28 |
+
json_object[key_list[cnt]]=f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}'
|
| 29 |
+
if json_object[key_list[cnt]]=='ZNNN':
|
| 30 |
+
#print ("Y")
|
| 31 |
+
a="Y"
|
| 32 |
+
b=0
|
| 33 |
+
c=0
|
| 34 |
+
d=0
|
| 35 |
+
if json_object[key_list[cnt]]=='YNNN':
|
| 36 |
+
#print("X")
|
| 37 |
+
a="X"
|
| 38 |
+
b=0
|
| 39 |
+
c=0
|
| 40 |
+
d=0
|
| 41 |
+
#print(cnt)
|
| 42 |
+
if cnt == key_cnt-1:
|
| 43 |
+
print('done')
|
| 44 |
+
go=False
|
| 45 |
+
print(list(json_object.keys())[-1])
|
| 46 |
+
else:
|
| 47 |
+
cnt+=1
|
| 48 |
+
|
| 49 |
+
#print(blob.tags) # [('The', 'DT'), ('titular', 'JJ'),
|
| 50 |
# ('threat', 'NN'), ('of', 'IN'), ...]
|
| 51 |
+
#print(blob.parse())
|
| 52 |
+
#print(blob.noun_phrases) # WordList(['titular threat', 'blob',
|
| 53 |
# 'ultimate movie monster',
|
| 54 |
# 'amoeba-like mass', ...])
|
| 55 |
+
return json_object
|
|
|
|
| 56 |
|
| 57 |
|
| 58 |
with gr.Blocks() as app:
|
|
|
|
| 61 |
inp = gr.Textbox(lines=10)
|
| 62 |
btn = gr.Button()
|
| 63 |
with gr.Column(scale=1):
|
| 64 |
+
nouns=gr.JSON(label="Nouns")
|
| 65 |
btn.click(get_nouns,inp,nouns)
|
| 66 |
app.launch()
|
| 67 |
|