<commit_before>module LLT
  class Diff::Parser
    class Word
      include HashContainable

      attr_accessor :form, :lemma, :head, :relation
      attr_reader :postag

      Attr = Struct.new(:attribute, :report_class) do
        def to_s
          attribute
        end

        def report
          Report.const_get(report_class.capitalize).new(attribute)
        end
      end

      %i{ lemma head relation }.each do |attr|
        define_method("#{attr}=") do |val|
          instance_variable_set("@#{attr}", Attr.new(val, attr))
        end
      end

      def postag=(tag)
        @postag = Postag.new(tag)
      end
    end
  end
end<commit_msg>More robust parsing for attributes we don't know<commit_after>module LLT
  class Diff::Parser
    class Word
      include HashContainable

      attr_accessor :form, :lemma, :head, :relation
      attr_reader :postag

      Attr = Struct.new(:attribute, :report_class) do
        def to_s
          attribute
        end

        def report
          Report.const_get(report_class.capitalize).new(attribute)
        end
      end

      %i{ lemma head relation }.each do |attr|
        define_method("#{attr}=") do |val|
          instance_variable_set("@#{attr}", Attr.new(val, attr))
        end
      end

      def postag=(tag)
        @postag = Postag.new(tag)
      end

      def method_missing(meth, *args, &blk)
        super unless meth =~ /=$/
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09778085991678225, 'fraction_numerical': 0.0, 'mean_word_length': 2.050739957716702, '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': '489108', 'n_tokens_mistral': 455, 'n_tokens_neox': 436, 'n_words': 116}