Spaces:
Running
Running
pragnakalp
commited on
Commit
•
a612f12
1
Parent(s):
698c7e0
Update app.py
Browse files
app.py
CHANGED
@@ -118,31 +118,35 @@ def get_emotion(text):
|
|
118 |
return label
|
119 |
|
120 |
def generate_emotion(article):
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
sen_list.
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
|
|
146 |
|
147 |
"""
|
148 |
Save generated details
|
@@ -181,7 +185,7 @@ def save_data_and_sendmail(article,results_dict,sen_list,results):
|
|
181 |
UI design for demo using gradio app
|
182 |
"""
|
183 |
inputs = gr.Textbox(value=SENTENCES_VALUE,lines=3, label="Sentences",elem_id="inp_div")
|
184 |
-
outputs = [gr.Dataframe(row_count = (3, "dynamic"), col_count=(2, "fixed"), label="Here is the Result", headers=["Input","Detected Emotion"])]
|
185 |
|
186 |
demo = gr.Interface(
|
187 |
generate_emotion,
|
@@ -189,10 +193,10 @@ demo = gr.Interface(
|
|
189 |
outputs,
|
190 |
title="Emotion Detection",
|
191 |
css=".gradio-container {background-color: lightgray} #inp_div {background-color: #FB3D5;}",
|
192 |
-
article="""Provide us your
|
193 |
-
|
194 |
We will be happy to serve you for your requirement. And don't forget to check out more interesting
|
195 |
-
|
196 |
-
|
197 |
)
|
198 |
demo.launch()
|
|
|
118 |
return label
|
119 |
|
120 |
def generate_emotion(article):
|
121 |
+
table = {'Input':[], 'Detected Emotion':[]}
|
122 |
+
if article.strip()
|
123 |
+
sen_list = article
|
124 |
+
sen_list = sen_list.split('\n')
|
125 |
+
while("" in sen_list):
|
126 |
+
sen_list.remove("")
|
127 |
+
sen_list_temp = sen_list[0:]
|
128 |
+
print(sen_list_temp)
|
129 |
+
results_dict = []
|
130 |
+
results = []
|
131 |
+
|
132 |
+
for sen in sen_list_temp:
|
133 |
+
if(sen.strip()):
|
134 |
+
cur_result = get_emotion(sen)
|
135 |
+
|
136 |
+
results.append(cur_result)
|
137 |
+
results_dict.append(
|
138 |
+
{
|
139 |
+
'sentence': sen,
|
140 |
+
'emotion': cur_result
|
141 |
+
}
|
142 |
+
)
|
143 |
+
|
144 |
+
table = {'Input':sen_list_temp, 'Detected Emotion':results}
|
145 |
+
gc.collect()
|
146 |
+
save_data_and_sendmail(article,results_dict,sen_list, table)
|
147 |
+
return pd.DataFrame(table)
|
148 |
+
else:
|
149 |
+
raise gr.Error("Please enter text in inputbox!!!!")
|
150 |
|
151 |
"""
|
152 |
Save generated details
|
|
|
185 |
UI design for demo using gradio app
|
186 |
"""
|
187 |
inputs = gr.Textbox(value=SENTENCES_VALUE,lines=3, label="Sentences",elem_id="inp_div")
|
188 |
+
outputs = [gr.Dataframe(row_count = (3, "dynamic"), col_count=(2, "fixed"), label="Here is the Result", headers=["Input","Detected Emotion"],wrap=True)]
|
189 |
|
190 |
demo = gr.Interface(
|
191 |
generate_emotion,
|
|
|
193 |
outputs,
|
194 |
title="Emotion Detection",
|
195 |
css=".gradio-container {background-color: lightgray} #inp_div {background-color: #FB3D5;}",
|
196 |
+
article="""<p style='text-align: center;'>Provide us your <a href="https://www.pragnakalp.com/contact/" target="_blank">feedback</a> on this demo and feel free
|
197 |
+
to contact us at <a href="mailto:letstalk@pragnakalp.com" target="_blank">letstalk@pragnakalp.com</a> if you want to have your own Emotion Detection system.
|
198 |
We will be happy to serve you for your requirement. And don't forget to check out more interesting
|
199 |
+
<a href="https://www.pragnakalp.com/services/natural-language-processing-services/" target="_blank">NLP services</a> we are offering.</p>
|
200 |
+
<p style='text-align: center;'>Developed by :<a href="https://www.pragnakalp.com" target="_blank">Pragnakalp Techlabs</a></p>"""
|
201 |
)
|
202 |
demo.launch()
|