duongthienz commited on
Commit
01639ca
·
verified ·
1 Parent(s): e6aae7c

Change formula for multi-file proportion graph

Browse files

I believe the denominator is incorrect and the float values can exceed 1.0

Files changed (1) hide show
  1. utils.py +10 -6
utils.py CHANGED
@@ -472,9 +472,6 @@ def build_multifile_category_df(validNames, results, summaries, categories, cate
472
  try:
473
  catSummary, extraCats = su.calcCategories(currAnnotation, per_file_selections)
474
  except (UnboundLocalError, Exception):
475
- # calcCategories can fail when a role contains a speaker with no
476
- # segments in this annotation (e.g. assigned in quick succession
477
- # before the UI has settled). Skip this file for the summary.
478
  summaries[fn]["categories"] = ([], [])
479
  continue
480
  # Apply display names to raw speaker IDs in extraCats
@@ -492,10 +489,17 @@ def build_multifile_category_df(validNames, results, summaries, categories, cate
492
  for fn in validNames:
493
  summary, extras = summaries[fn]["categories"]
494
  theseCategories = categories + extras
 
 
 
 
 
 
 
 
495
  for j, timeSlots in enumerate(summary):
496
- df6_dict[theseCategories[j]].append(
497
- sum(t.duration for _, t in timeSlots) / results[fn][1]
498
- )
499
  for category in allCategories:
500
  if category not in theseCategories:
501
  df6_dict[category].append(0)
 
472
  try:
473
  catSummary, extraCats = su.calcCategories(currAnnotation, per_file_selections)
474
  except (UnboundLocalError, Exception):
 
 
 
475
  summaries[fn]["categories"] = ([], [])
476
  continue
477
  # Apply display names to raw speaker IDs in extraCats
 
489
  for fn in validNames:
490
  summary, extras = summaries[fn]["categories"]
491
  theseCategories = categories + extras
492
+ # Use the annotation's actual span as denominator, falling back to
493
+ # results[fn][1]. This avoids >1.0 values when totalSeconds was
494
+ # truncated to int or is slightly shorter than the last segment end.
495
+ annotation_end = max(
496
+ (s.end for s in results[fn][0].itersegments()),
497
+ default=results[fn][1]
498
+ )
499
+ safe_total = max(annotation_end, results[fn][1], 1)
500
  for j, timeSlots in enumerate(summary):
501
+ val = sum(t.duration for _, t in timeSlots) / safe_total
502
+ df6_dict[theseCategories[j]].append(min(val, 1.0))
 
503
  for category in allCategories:
504
  if category not in theseCategories:
505
  df6_dict[category].append(0)