elselse commited on
Commit
2c3bbb9
·
verified ·
1 Parent(s): bcd6411

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -36,7 +36,10 @@ def predict_cwe(commit_message: str):
36
  # Map predictions to parent CWE (if available)
37
  mapped_results = {}
38
  for item in sorted_results[:5]:
39
- mapped_results[item["label"]] = round(float(item["score"]), 4)
 
 
 
40
  return mapped_results
41
 
42
  # Gradio UI
 
36
  # Map predictions to parent CWE (if available)
37
  mapped_results = {}
38
  for item in sorted_results[:5]:
39
+ child_cwe = item["label"].replace("CWE-", "")
40
+ parent_cwe = child_to_parent.get(child_cwe, child_cwe) # default to child if no parent
41
+ mapped_results[f"CWE-{parent_cwe}"] = round(float(item["score"]), 4)
42
+
43
  return mapped_results
44
 
45
  # Gradio UI