Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -102,11 +102,15 @@ def get_db_connection():
|
|
| 102 |
return conn
|
| 103 |
|
| 104 |
def node_url_to_label(url: str) -> str:
|
| 105 |
-
"""
|
| 106 |
try:
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
| 108 |
except:
|
| 109 |
-
|
|
|
|
| 110 |
|
| 111 |
def get_semantic_profile(word: str, lang: str = 'en', selected_relations: List[str] = None, progress=gr.Progress()):
|
| 112 |
"""
|
|
|
|
| 102 |
return conn
|
| 103 |
|
| 104 |
def node_url_to_label(url: str) -> str:
|
| 105 |
+
"""Extract the term from ConceptNet URL: /c/{lang}/{term}/..."""
|
| 106 |
try:
|
| 107 |
+
parts = url.split('/')
|
| 108 |
+
if len(parts) >= 4:
|
| 109 |
+
# Index 3 is the term, regardless of whether there's a POS tag
|
| 110 |
+
return parts[3].replace('_', ' ')
|
| 111 |
except:
|
| 112 |
+
pass
|
| 113 |
+
return url # fallback
|
| 114 |
|
| 115 |
def get_semantic_profile(word: str, lang: str = 'en', selected_relations: List[str] = None, progress=gr.Progress()):
|
| 116 |
"""
|