def RelaxBoundaryTruncation(self):
    assert (self.start_unk_padding == self.end_unk_padding == 0.0)
    if (self.start_keep_proportion == self.end_keep_proportion == 1.0):
        return
    length_cutoff = max(args.min_new_segment_length, args.min_segment_length)
    length_with_truncation = self.Length()
    if (length_with_truncation >= length_cutoff):
        return
    orig_start_keep_proportion = self.start_keep_proportion
    orig_end_keep_proportion = self.end_keep_proportion
    if (not IsTainted(self.split_lines_of_utt[self.start_index])):
        self.start_keep_proportion = 1.0
    if (not IsTainted(self.split_lines_of_utt[(self.end_index - 1)])):
        self.end_keep_proportion = 1.0
    length_with_relaxed_boundaries = self.Length()
    if (length_with_relaxed_boundaries <= length_cutoff):
        return
    a = ((length_cutoff - length_with_relaxed_boundaries) / (length_with_truncation - length_with_relaxed_boundaries))
    if ((a < 0.0) or (a > 1.0)):
        print("segment_ctm_edits.py: bad 'a' value = {0}".format(a), file=sys.stderr)
        return
    self.start_keep_proportion = ((a * orig_start_keep_proportion) + ((1 - a) * self.start_keep_proportion))
    self.end_keep_proportion = ((a * orig_end_keep_proportion) + ((1 - a) * self.end_keep_proportion))
    if (not (abs((self.Length() - length_cutoff)) < 0.01)):
        print('segment_ctm_edits.py: possible problem relaxing boundary truncation, length is {0} vs {1}'.format(self.Length(), length_cutoff), file=sys.stderr)
def RelaxBoundaryTruncation(self):
    assert (self.start_unk_padding == self.end_unk_padding == 0.0)
    if (self.start_keep_proportion == self.end_keep_proportion == 1.0):
        return
    length_cutoff = max(args.min_new_segment_length, args.min_segment_length)
    length_with_truncation = self.Length()
    if (length_with_truncation >= length_cutoff):
        return
    orig_start_keep_proportion = self.start_keep_proportion
    orig_end_keep_proportion = self.end_keep_proportion
    if (not IsTainted(self.split_lines_of_utt[self.start_index])):
        self.start_keep_proportion = 1.0
    if (not IsTainted(self.split_lines_of_utt[(self.end_index - 1)])):
        self.end_keep_proportion = 1.0
    length_with_relaxed_boundaries = self.Length()
    if (length_with_relaxed_boundaries <= length_cutoff):
        return
    a = ((length_cutoff - length_with_relaxed_boundaries) / (length_with_truncation - length_with_relaxed_boundaries))
    if ((a < 0.0) or (a > 1.0)):
        print("segment_ctm_edits.py: bad 'a' value = {0}".format(a), file=sys.stderr)
        return
    self.start_keep_proportion = ((a * orig_start_keep_proportion) + ((1 - a) * self.start_keep_proportion))
    self.end_keep_proportion = ((a * orig_end_keep_proportion) + ((1 - a) * self.end_keep_proportion))
    if (not (abs((self.Length() - length_cutoff)) < 0.01)):
        print('segment_ctm_edits.py: possible problem relaxing boundary truncation, length is {0} vs {1}'.format(self.Length(), length_cutoff), file=sys.stderr)