Spaces:
Sleeping
Sleeping
Shunfeng Zheng
commited on
Update 1_SpatialParse.py
Browse files- 1_SpatialParse.py +22 -22
1_SpatialParse.py
CHANGED
|
@@ -13,25 +13,25 @@ import urllib.parse
|
|
| 13 |
import os
|
| 14 |
import requests
|
| 15 |
|
| 16 |
-
API_TOKEN = 'hf_'
|
| 17 |
-
BACKEND_URL = "https://dsbb0707-dockerb2.hf.space/api/predict/"
|
| 18 |
-
def call_backend(input_text):
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
|
| 36 |
|
| 37 |
colors = {'GPE': "#43c6fc", "LOC": "#fd9720", "RSE":"#a6e22d"}
|
|
@@ -224,9 +224,9 @@ def extract_spatial_entities(text):
|
|
| 224 |
# # doc.to_disk("saved_doc.spacy")
|
| 225 |
# doc.to_disk("/tmp/saved_doc.spacy")
|
| 226 |
|
| 227 |
-
api_result = call_backend(text)
|
| 228 |
-
st.markdown(api_result)
|
| 229 |
-
st.text_area(api_result)
|
| 230 |
|
| 231 |
# html = displacy.render(doc,style="ent", options = options)
|
| 232 |
# html = html.replace("\n","")
|
|
|
|
| 13 |
import os
|
| 14 |
import requests
|
| 15 |
|
| 16 |
+
# API_TOKEN = 'hf_'
|
| 17 |
+
# BACKEND_URL = "https://dsbb0707-dockerb2.hf.space/api/predict/"
|
| 18 |
+
# def call_backend(input_text):
|
| 19 |
+
# try:
|
| 20 |
+
# headers = {
|
| 21 |
+
# "Authorization": f"Bearer {API_TOKEN}"
|
| 22 |
+
# }
|
| 23 |
+
# response = requests.post(
|
| 24 |
+
# BACKEND_URL,
|
| 25 |
+
# headers=headers,
|
| 26 |
+
# json={"data": [input_text]},
|
| 27 |
+
# timeout=10
|
| 28 |
+
# )
|
| 29 |
+
# if response.status_code == 200:
|
| 30 |
+
# result = response.json()["data"][0]
|
| 31 |
+
# return f"✅ {result['result']}\n⏰ {result['timestamp']}"
|
| 32 |
+
# return f"❌ Backend Error (HTTP {response.status_code})"
|
| 33 |
+
# except Exception as e:
|
| 34 |
+
# return f"⚠️ Connection Error: {str(e)}"
|
| 35 |
|
| 36 |
|
| 37 |
colors = {'GPE': "#43c6fc", "LOC": "#fd9720", "RSE":"#a6e22d"}
|
|
|
|
| 224 |
# # doc.to_disk("saved_doc.spacy")
|
| 225 |
# doc.to_disk("/tmp/saved_doc.spacy")
|
| 226 |
|
| 227 |
+
# api_result = call_backend(text)
|
| 228 |
+
# st.markdown(api_result)
|
| 229 |
+
# st.text_area(api_result)
|
| 230 |
|
| 231 |
# html = displacy.render(doc,style="ent", options = options)
|
| 232 |
# html = html.replace("\n","")
|