<commit_before>module Munge
  module Attribute
    class Content
      def self.match(string)
        string.match(/
          # Start of string
          \A
          # Begin frontmatter
          (?:^---\s*[\n\r]+)   
          # Capture frontmatter
          (.*)
          # End frontmatter
          (?:^---\s*[\n\r]+)
          /mx)
      end

      def self.parse(string)
        matchdata = match(string)

        [
          parse_frontmatter(matchdata),
          parse_content(matchdata, string)
        ]
      end

      def self.parse_frontmatter(matchdata)
        return {} if matchdata.nil?

        parsed_frontmatter = YAML.load(matchdata[1])

        if parsed_frontmatter
          parsed_frontmatter
        else
          {}
        end
      end

      def self.parse_content(matchdata, string)
        if matchdata
          matchdata.post_match
        else
          string
        end
      end

      def initialize(string)
        @frontmatter, @content = self.class.parse(string)
      end

      attr_reader :frontmatter, :content
    end
  end
end
<commit_msg>rubocop<commit_after>module Munge
  module Attribute
    class Content
      def self.match(string)
        string.match(/
          # Start of string
          \A
          # Begin frontmatter
          (?:^---\s*[\n\r]+)
          # Capture frontmatter
          (.*)
          # End frontmatter
          (?:^---\s*[\n\r]+)
          /mx)
      end

      def self.parse(string)
        matchdata = match(string)

        [
          parse_frontmatter(matchdata),
          parse_content(matchdata, string)
        ]
      end

      def self.parse_frontmatter(matchdata)
        return {} if matchdata.nil?

        parsed_frontmatter = YAML.load(matchdata[1])

        if parsed_frontmatter
          parsed_frontmatter
        else
          {}
        end
      end

      def self.parse_content(matchdata, string)
        if matchdata
          matchdata.post_match
        else
          string
        end
      end

      def initialize(string)
        @frontmatter, @content = self.class.parse(string)
      end

      attr_reader :frontmatter, :content
    end
  end
end

{'fraction_non_alphanumeric': 0.0891134588883785, 'fraction_numerical': 0.0009186954524575103, 'mean_word_length': 1.4417040358744395, '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': '4714457', 'n_tokens_mistral': 652, 'n_tokens_neox': 611, 'n_words': 132}