emanuelaboros
commited on
Commit
•
80a6ddf
1
Parent(s):
3cf0565
Update generic_nel.py
Browse files- generic_nel.py +9 -1
generic_nel.py
CHANGED
@@ -70,7 +70,15 @@ def get_wikipedia_title(qid, language="en"):
|
|
70 |
}
|
71 |
|
72 |
response = requests.get(url, params=params)
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
try:
|
76 |
title = data["entities"][qid]["sitelinks"][f"{language}wiki"]["title"]
|
|
|
70 |
}
|
71 |
|
72 |
response = requests.get(url, params=params)
|
73 |
+
try:
|
74 |
+
response.raise_for_status() # Raise an HTTPError if the response was not 2xx
|
75 |
+
data = response.json()
|
76 |
+
except requests.exceptions.RequestException as e:
|
77 |
+
print(f"HTTP error: {e}")
|
78 |
+
return "NIL", "None"
|
79 |
+
except ValueError as e: # Catch JSON decode errors
|
80 |
+
print(f"Invalid JSON response: {response.text}")
|
81 |
+
return "NIL", "None"
|
82 |
|
83 |
try:
|
84 |
title = data["entities"][qid]["sitelinks"][f"{language}wiki"]["title"]
|