<commit_before>class ScheduleParser
  class << self
    def parse(original, time_zone: 'UTC', target_date: nil)
      text = original
      text = text.gsub(/[\n\r]/, ' ')
      text = text.gsub(/(?<hour>\d{2})(?<minutes>\d{2})[ 　]*[-〜~]/, '\k<hour>:\k<minutes>')
      regexp = /(夜|午後|夕方)[ 　]*(\d{1,2})時(\d{1,2}分)?/
      if matches = text.match(regexp)
        hour = matches[2].to_i
        if hour < 12
          hour += 12
        end
        minutes = 0
        if matches.length > 3
          minutes = matches[3].to_i
        end
        text = text.gsub(regexp, format('%02d:%02d', hour, minutes))
      end
      text = text.gsub(/(?<hour>\d{2}):(?<minutes>\d{2})/, ' \k<hour>:\k<minutes> ')
      text = text.gsub(/(?<month>\d{1,2})\/(?<day>\d{1,2})/, '\k<month>月\k<day>日')

      schedule = {datetime: [], location: '', title: '', description: ''}
      response = {}
      TaggerWrapper.name_entity_extraction(text, time_zone: time_zone, target_date: target_date) do |item|
        key = item.keys.first
        response[key] = [] if response[key].blank?
        response[key] << item[key]
        response[key].uniq!
      end

      if response[:date].present? && response[:time].present?
        response[:time].length.times do |i|
          schedule[:datetime] << (response[:date][0].strftime('%F') + ' ' + response[:time][i].strftime('%T')).in_time_zone(time_zone)
        end
      end

      locations = []
      locations << response[:location] if response[:location].present?
      locations << response[:artifact] if response[:artifact].present?
      schedule[:location] = locations.flatten.uniq.join(' ')

      title_tmp = []
      title_tmp << response[:artifact] if response[:artifact].present?
      title_tmp << response[:person] if response[:person].present?
      title_tmp << response[:organization] if response[:organization].present?

      schedule[:title] = title_tmp.flatten.uniq.join(' ')
      schedule[:description] = original

      schedule
    end
  end<commit_msg>Modify schedule_parser<commit_after>class ScheduleParser
  class << self
    def parse(original, time_zone: 'UTC', target_date: nil)
      text = original
      text = text.gsub(/[\n\r]/, ' ')
      text = text.gsub(/(?<hour>\d{2})(?<minutes>\d{2})[ 　]*[-〜~]/, '\k<hour>:\k<minutes>')
      regexp = /(夜|午後|夕方)[ 　]*(\d{1,2})時(\d{1,2}分)?/
      if matches = text.match(regexp)
        hour = matches[2].to_i
        if hour < 12
          hour += 12
        end
        minutes = 0
        if matches.length > 3
          minutes = matches[3].to_i
        end
        text = text.gsub(regexp, format('%02d:%02d', hour, minutes))
      end
      text = text.gsub(/(?<hour>\d{2}):(?<minutes>\d{2})/, ' \k<hour>:\k<minutes> ')
      text = text.gsub(/(?<month>\d{1,2})\/(?<day>\d{1,2})/, '\k<month>月\k<day>日')

      schedule = {datetime: [], location: '', title: '', description: ''}
      response = {}
      TaggerWrapper.name_entity_extraction(text, time_zone: time_zone, target_date: target_date) do |item|
        key = item.keys.first
        response[key] = [] if response[key].blank?
        response[key] << item[key]
        response[key].uniq!
      end

      if response[:date].present? && response[:time].present?
        response[:time].length.times do |i|
          schedule[:datetime] << (response[:date][0].strftime('%F') + ' ' + response[:time][i].strftime('%T')).in_time_zone(time_zone)
        end
      end

      locations = []
      locations << response[:location] if response[:location].present?
      schedule[:location] = locations.flatten.uniq.join(' ')

      title_tmp = []
      title_tmp << response[:artifact] if response[:artifact].present?
      title_tmp << response[:person] if response[:person].present?
      title_tmp << response[:organization] if response[:organization].present?

      schedule[:title] = title_tmp.flatten.uniq.join(' ')
      schedule[:description] = original

      schedule
    end
  end
{'fraction_non_alphanumeric': 0.1890798786653185, 'fraction_numerical': 0.012639029322548028, 'mean_word_length': 2.7685714285714287, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 29, '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': '4083079', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1305, 'n_words': 228}