<commit_before># encoding: UTF-8
class PerobaPlugin
  parse_peroba = lambda do |url|
    # Result hash where the key is date and value an array of lunch item descriptions as strings.
    parsed_results = {}

    begin
      puts "PerobaPlugin parsing url: #{url}"

      doc = ParserUtils.get_html_doc(url)
      content_arr = doc.css('#menu > *').map {|e| LunchItemCleanser.cleanse(e.text)}

      content_arr.shift while content_arr.first.nil?
      lunch_week_number = content_arr.shift[/\d{1,2}/].to_i

      today = Date.today

      if today.cweek == lunch_week_number
        monday = ParserUtils.find_previous_monday(today)

        for i in 0..4
          content_arr.shift while content_arr.first.nil?  || content_arr.first =~ /(maanantai|tiistai|keskiviikko|torstai|perjantai)/i
          lunch_items = []

          until content_arr.first.nil?  || content_arr.first =~ /(maanantai|tiistai|keskiviikko|torstai|perjantai)/i
            lunch_items << content_arr.shift.gsub(/\s\|.*$/, '')
          end

          parsed_results[monday + i] = lunch_items
        end

      end
    rescue
      STDERR.puts "PerobaPlugin failed to scrape info from #{url}: #{$!}"
    end

    return parsed_results
  end

  RestaurantProcessor.register_parser(/perobacafe\.fi/, parse_peroba)
end<commit_msg>Small tweak on Peroba plugin.<commit_after># encoding: UTF-8
class PerobaPlugin
  parse_peroba = lambda do |url|
    # Result hash where the key is date and value an array of lunch item descriptions as strings.
    parsed_results = {}

    begin
      puts "PerobaPlugin parsing url: #{url}"

      doc = ParserUtils.get_html_doc(url)
      content_arr = doc.css('#menu > *').map {|e| LunchItemCleanser.cleanse(e.text)}

      content_arr.shift while content_arr.first.nil?
      lunch_week_number = content_arr.shift[/\d{1,2}/].to_i

      today = Date.today

      if today.cweek == lunch_week_number
        monday = ParserUtils.find_previous_monday(today)

        for i in 0..4
          content_arr.shift while content_arr.first.nil?  || content_arr.first =~ /(maanantai|tiistai|keskiviikko|torstai|perjantai)/i
          lunch_items = []

          until content_arr.first.nil?  || content_arr.first =~ /(maanantai|tiistai|keskiviikko|torstai|perjantai)/i
            lunch_items << content_arr.shift.gsub(/\s*\|.*$/, '')
          end

          parsed_results[monday + i] = lunch_items
        end

      end
    rescue
      STDERR.puts "PerobaPlugin failed to scrape info from #{url}: #{$!}"
    end

    return parsed_results
  end

  RestaurantProcessor.register_parser(/perobacafe\.fi/, parse_peroba)
end
{'fraction_non_alphanumeric': 0.11149293623520427, 'fraction_numerical': 0.0038182512409316535, 'mean_word_length': 2.841642228739003, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '231846', 'n_tokens_mistral': 894, 'n_tokens_neox': 870, 'n_words': 183}