Khriis commited on
Commit
c4e871c
verified
1 Parent(s): 34873e0

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +7 -1
handler.py CHANGED
@@ -249,7 +249,13 @@ class EndpointHandler:
249
  "char_len": len(s_norm)
250
  })
251
 
252
- candidates.sort(key=lambda x: (x["tok_len"], x["char_len"]), reverse=True)
 
 
 
 
 
 
253
  kept_norms = []
254
  for c in list(candidates):
255
  n = c["norm"]
 
249
  "char_len": len(s_norm)
250
  })
251
 
252
+ # Prioritize short, focused emotional keywords (1-3 words)
253
+ short_candidates = [c for c in candidates if 1 <= c["tok_len"] <= 3]
254
+ if short_candidates:
255
+ candidates = short_candidates
256
+
257
+ # Sort by SHORTEST spans first (most focused keywords)
258
+ candidates.sort(key=lambda x: (x["tok_len"], x["char_len"]), reverse=False)
259
  kept_norms = []
260
  for c in list(candidates):
261
  n = c["norm"]