Macrodove commited on
Commit
a03ab93
1 Parent(s): 5543434

Former-commit-id: b46106e7862c6c68e5e4065447a46dc00586a834

Files changed (1) hide show
  1. evaluation/alignment.py +9 -3
evaluation/alignment.py CHANGED
@@ -111,12 +111,12 @@ def alignment(pred_path, gt_path, threshold=0.5):
111
  gs = gt[idx_t] if idx_t < len(gt) else empt
112
 
113
  # Merging sequence for pred
114
- while idx_p + 1 < len(pred) and abs(pred[idx_p + 1].end - gs.end) <= threshold:
115
  ps += pred[idx_p + 1]
116
  idx_p += 1
117
 
118
  # Merging sequence for gt
119
- while idx_t + 1 < len(gt) and abs(gt[idx_t + 1].end - ps.end) <= threshold:
120
  gs += gt[idx_t + 1]
121
  idx_t += 1
122
 
@@ -126,8 +126,14 @@ def alignment(pred_path, gt_path, threshold=0.5):
126
  idx_p += 1
127
  idx_t += 1
128
 
 
 
 
 
 
 
129
  return zip(pred_arr, gt_arr)
130
 
131
 
132
  # Test Case
133
- #alignment('test_translation_zh.srt', 'test_translation_bi.srt')
 
111
  gs = gt[idx_t] if idx_t < len(gt) else empt
112
 
113
  # Merging sequence for pred
114
+ while idx_p + 1 < len(pred) and pred[idx_p + 1].end <= gs.end + threshold:
115
  ps += pred[idx_p + 1]
116
  idx_p += 1
117
 
118
  # Merging sequence for gt
119
+ while idx_t + 1 < len(gt) and gt[idx_t + 1].end <= ps.end + threshold:
120
  gs += gt[idx_t + 1]
121
  idx_t += 1
122
 
 
126
  idx_p += 1
127
  idx_t += 1
128
 
129
+
130
+ #for a in pred_arr:
131
+ # print(a.translation)
132
+ #for a in gt_arr:
133
+ # print(a.source_text)
134
+
135
  return zip(pred_arr, gt_arr)
136
 
137
 
138
  # Test Case
139
+ #alignment('test_translation_s2.srt', 'test_translation_zh.srt')