Spaces:
Running
Running
Commit
·
f4c86b6
1
Parent(s):
4fbea90
Update app.py
Browse files
app.py
CHANGED
|
@@ -130,41 +130,38 @@ def get_location(ip_addr):
|
|
| 130 |
print("response======>>",response)
|
| 131 |
return response
|
| 132 |
|
| 133 |
-
def
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
k
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
|
| 158 |
def save_data_and_sendmail(article,output):
|
| 159 |
try:
|
| 160 |
print("welcome")
|
| 161 |
ip_address = ''
|
| 162 |
-
# ip_address = get_device_ip_address()
|
| 163 |
-
# ip_address=str(request.remote_addr)
|
| 164 |
-
# print(ip_address)
|
| 165 |
-
# location = get_location(ip_address)
|
| 166 |
-
# location = get_location(ip_address)
|
| 167 |
-
# print(ip_address)
|
| 168 |
|
| 169 |
ip_address= getIP()
|
| 170 |
print(ip_address)
|
|
@@ -194,7 +191,7 @@ def save_data_and_sendmail(article,output):
|
|
| 194 |
return "Error while sending mail" + str(e)
|
| 195 |
|
| 196 |
input=gr.Textbox(lines=3, value=input_value, label="Input Text")
|
| 197 |
-
output = [gr.Dataframe(row_count = (2, "dynamic"), col_count=(2, "fixed"), headers=["Entities Found","Entity Types"], lable="Here is the result")]
|
| 198 |
# with gr.Blocks(css=".gradio-container {background-color: lightgray}") as demo:
|
| 199 |
# gr.Markdown("<h1 style='text-align: center;'>"+ "Named Entity Recognition Using BERT" + "</h1><br/><br/>")
|
| 200 |
# with gr.Row():
|
|
@@ -215,14 +212,15 @@ output = [gr.Dataframe(row_count = (2, "dynamic"), col_count=(2, "fixed"), heade
|
|
| 215 |
# demo.launch()
|
| 216 |
|
| 217 |
demo = gr.Interface(
|
| 218 |
-
|
| 219 |
input,
|
| 220 |
output,
|
| 221 |
title="Named Entity Recognition Using BERT",
|
| 222 |
css=".gradio-container {background-color: lightgray} #inp_div {background-color: #7FB3D5;",
|
| 223 |
-
article="""Feel free to give us your
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
|
|
|
| 227 |
)
|
| 228 |
demo.launch()
|
|
|
|
| 130 |
print("response======>>",response)
|
| 131 |
return response
|
| 132 |
|
| 133 |
+
def generate_ner(article):
|
| 134 |
+
result = {'Entities Found':[], 'Entity Types':[]}
|
| 135 |
+
if article.strip():
|
| 136 |
+
text = "Input sentence: "
|
| 137 |
+
text += article
|
| 138 |
+
|
| 139 |
+
model_ner = Ner(bert_ner_model)
|
| 140 |
+
|
| 141 |
+
output = model_ner.predict(text)
|
| 142 |
+
print(output)
|
| 143 |
+
k = 0
|
| 144 |
+
Entities_Found.clear()
|
| 145 |
+
Entity_Types.clear()
|
| 146 |
+
save_data_and_sendmail(article,output)
|
| 147 |
+
for i in output:
|
| 148 |
+
for j in i:
|
| 149 |
+
if k == 0:
|
| 150 |
+
Entities_Found.append(j)
|
| 151 |
+
k += 1
|
| 152 |
+
else:
|
| 153 |
+
Entity_Types.append(j)
|
| 154 |
+
k = 0
|
| 155 |
+
result = {'Entities Found':Entities_Found, 'Entity Types':Entity_Types}
|
| 156 |
+
return pd.DataFrame(result)
|
| 157 |
+
else:
|
| 158 |
+
raise gr.Error("Please enter text in inputbox!!!!")
|
| 159 |
|
| 160 |
|
| 161 |
def save_data_and_sendmail(article,output):
|
| 162 |
try:
|
| 163 |
print("welcome")
|
| 164 |
ip_address = ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
ip_address= getIP()
|
| 167 |
print(ip_address)
|
|
|
|
| 191 |
return "Error while sending mail" + str(e)
|
| 192 |
|
| 193 |
input=gr.Textbox(lines=3, value=input_value, label="Input Text")
|
| 194 |
+
output = [gr.Dataframe(row_count = (2, "dynamic"), col_count=(2, "fixed"), headers=["Entities Found","Entity Types"], lable="Here is the result"),wrap=True]
|
| 195 |
# with gr.Blocks(css=".gradio-container {background-color: lightgray}") as demo:
|
| 196 |
# gr.Markdown("<h1 style='text-align: center;'>"+ "Named Entity Recognition Using BERT" + "</h1><br/><br/>")
|
| 197 |
# with gr.Row():
|
|
|
|
| 212 |
# demo.launch()
|
| 213 |
|
| 214 |
demo = gr.Interface(
|
| 215 |
+
generate_ner,
|
| 216 |
input,
|
| 217 |
output,
|
| 218 |
title="Named Entity Recognition Using BERT",
|
| 219 |
css=".gradio-container {background-color: lightgray} #inp_div {background-color: #7FB3D5;",
|
| 220 |
+
article="""<p style='text-align: center;'>Feel free to give us your <a href="https://www.pragnakalp.com/contact/" target="_blank">feedback</a> on this NER demo.
|
| 221 |
+
For all your Named Entity Recognition related requirements, we are here to help you. Email us your requirement at
|
| 222 |
+
<a href="mailto:letstalk@pragnakalp.com" target="_blank">letstalk@pragnakalp.com</a>. And don't forget to check out more interesting
|
| 223 |
+
<a href="https://www.pragnakalp.com/services/natural-language-processing-services/" target="_blank">NLP services</a> we are offering.
|
| 224 |
+
<p style='text-align: center;'>Developed by :<a href="https://www.pragnakalp.com" target="_blank"> Pragnakalp Techlabs</a></p>"""
|
| 225 |
)
|
| 226 |
demo.launch()
|