JiaenLiu commited on
Commit
9ad8b62
1 Parent(s): e3825f8

in progress

Browse files

Former-commit-id: d430cf9b82d39e3a9bf4049be61cb9ebd681fa10

Files changed (1) hide show
  1. SRT.py +11 -4
SRT.py CHANGED
@@ -233,7 +233,7 @@ class SRT_script():
233
  return result_list
234
 
235
 
236
- def check_len_and_split(self, threshold=30):
237
  # TODO: if sentence length >= threshold, split this segments to two
238
  segments = []
239
  for seg in self.segments:
@@ -247,7 +247,7 @@ class SRT_script():
247
 
248
  pass
249
 
250
- def check_len_and_split_range(self, range, threshold=30):
251
  # TODO: if sentence length >= threshold, split this segments to two
252
  start_seg_id = range[0]
253
  end_seg_id = range[1]
@@ -406,7 +406,12 @@ class SRT_script():
406
  start_seg_id = range[0]
407
  end_seg_id = range[1]
408
  with open(path, "a", encoding='utf-8') as f:
409
- for i, seg in enumerate(self.segments[start_seg_id-1:end_seg_id+length]):
 
 
 
 
 
410
  f.write(f'{i+idx}\n')
411
  f.write(seg.get_trans_str())
412
  pass
@@ -415,7 +420,9 @@ class SRT_script():
415
  start_seg_id = range[0]
416
  end_seg_id = range[1]
417
  with open(path, "a", encoding='utf-8') as f:
418
- for i, seg in enumerate(self.segments[start_seg_id-1:end_seg_id+length]):
 
 
419
  f.write(f'{i+idx}\n')
420
  f.write(seg.get_bilingual_str())
421
  pass
 
233
  return result_list
234
 
235
 
236
+ def check_len_and_split(self, threshold=30000):
237
  # TODO: if sentence length >= threshold, split this segments to two
238
  segments = []
239
  for seg in self.segments:
 
247
 
248
  pass
249
 
250
+ def check_len_and_split_range(self, range, threshold=30000):
251
  # TODO: if sentence length >= threshold, split this segments to two
252
  start_seg_id = range[0]
253
  end_seg_id = range[1]
 
406
  start_seg_id = range[0]
407
  end_seg_id = range[1]
408
  with open(path, "a", encoding='utf-8') as f:
409
+ # for i, seg in enumerate(self.segments[start_seg_id-1:end_seg_id+length]):
410
+ # f.write(f'{i+idx}\n')
411
+ # f.write(seg.get_trans_str())
412
+ for i, seg in enumerate(self.segments):
413
+ if i<range[0]-1: continue
414
+ if i>=range[1]:break
415
  f.write(f'{i+idx}\n')
416
  f.write(seg.get_trans_str())
417
  pass
 
420
  start_seg_id = range[0]
421
  end_seg_id = range[1]
422
  with open(path, "a", encoding='utf-8') as f:
423
+ for i, seg in enumerate(self.segments):
424
+ if i<range[0]-1: continue
425
+ if i>=range[1]:break
426
  f.write(f'{i+idx}\n')
427
  f.write(seg.get_bilingual_str())
428
  pass