cstr commited on
Commit
fefc16c
·
verified ·
1 Parent(s): 3015d12

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
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
- """Helper to turn '.../c/en/dog_house' into 'dog house'."""
106
  try:
107
- return url.split('/')[-1].replace('_', ' ')
 
 
 
108
  except:
109
- return url
 
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
  """