<commit_before>import logging
import sys
import codecs
import os


class TimeOffset(object):
    __slots__ = ['seconds']

    def __init__(self, seconds=None):
        super(TimeOffset, self).__init__()
        self.seconds = seconds

    @staticmethod
    def from_seconds(seconds):
        return TimeOffset(seconds=seconds)

    @staticmethod
    def from_ass_string(string):
        hours, minutes, seconds = map(float, string.split(':'))
        return TimeOffset(hours*3600+minutes*60+seconds)

    @staticmethod
    def from_srt_string(string):
        return TimeOffset.from_ass_string(string.replace(',','.'))

    def add_seconds(self, offset):
        self.seconds += offset

    @property
    def total_seconds(self):
        return self.seconds

    def to_ass_time_string(self):
        return u'{0}:{1:02d}:{2:02d}.{3:02d}'.format(
            int(self.seconds // 3600),
            int((self.seconds // 60) % 60),
            int(self.seconds % 60),
            int(round((self.seconds % 1) * 100)))

    def to_srt_time_string(self):
        return u'{0:02d}:{1:02d}:{2:02d},{3:03d}'.format(<commit_msg>Clip times to zero to avoid negatives<commit_after>import logging
import sys
import codecs
import os


class TimeOffset(object):
    __slots__ = ['seconds']

    def __init__(self, seconds=None):
        super(TimeOffset, self).__init__()
        self.seconds = seconds

    @staticmethod
    def from_seconds(seconds):
        return TimeOffset(seconds=seconds)

    @staticmethod
    def from_ass_string(string):
        hours, minutes, seconds = map(float, string.split(':'))
        return TimeOffset(hours*3600+minutes*60+seconds)

    @staticmethod
    def from_srt_string(string):
        return TimeOffset.from_ass_string(string.replace(',','.'))

    def add_seconds(self, offset):
        self.seconds = max(0, self.seconds + offset)

    @property
    def total_seconds(self):
        return self.seconds

    def to_ass_time_string(self):
        return u'{0}:{1:02d}:{2:02d}.{3:02d}'.format(
            int(self.seconds // 3600),
            int((self.seconds // 60) % 60),
            int(self.seconds % 60),
            int(round((self.seconds % 1) * 100)))

    def to_srt_time_string(self):
        return u'{0:02d}:{1:02d}:{2:02d},{3:03d}'.format(
{'fraction_non_alphanumeric': 0.1373578302712161, 'fraction_numerical': 0.03718285214348206, 'mean_word_length': 2.93631669535284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4052191', 'n_tokens_mistral': 795, 'n_tokens_neox': 725, 'n_words': 141}