<commit_before>#encoding: utf-8
module Shoutout
  class Metadata < Hash
    def self.parse(raw_metadata)
      metadata = {}
      raw_metadata.split(";").each do |key_value_pair|
        key, value = key_value_pair.split("=", 2)
        if value != nil
          valuetaken = value.match(/\A'(.*)'\z/)
          if valuetaken != nil
            metadata[key] = valuetaken[1].ensure_encoding('UTF-8',
                                                                         :external_encoding  => :sniff,
                                                                         :invalid_characters => :transcode
            )
          end
        end
      end

      new(metadata)
    end

    def initialize(constructor = {})<commit_msg>change invalid characters setting to drop<commit_after>#encoding: utf-8
module Shoutout
  class Metadata < Hash
    def self.parse(raw_metadata)
      metadata = {}
      raw_metadata.split(";").each do |key_value_pair|
        key, value = key_value_pair.split("=", 2)
        if value != nil
          valuetaken = value.match(/\A'(.*)'\z/)
          if valuetaken != nil
            metadata[key] = valuetaken[1].ensure_encoding('UTF-8',
                                                                         :external_encoding  => :sniff,
                                                                         :invalid_characters => :drop
            )
          end
        end
      end

      new(metadata)
    end

    def initialize(constructor = {})
{'fraction_non_alphanumeric': 0.10246174318030606, 'fraction_numerical': 0.0053226879574184965, 'mean_word_length': 1.2719033232628398, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '738404', 'n_tokens_mistral': 381, 'n_tokens_neox': 370, 'n_words': 81}