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

      attr_accessor :lemma, :postag, :head, :relation

      def to_xml
        as_xml
      end

      def as_xml
        grouped_differences.map { |type, val| "<#{type} #{to_xml_attrs(val)}/>" }.join
      end

      DIFFERENCES = %i{ lemma postag head relation }
      def grouped_differences
        res = { original: {}, new: {} }
        DIFFERENCES.each do |var|
          if diff = send(var)
            res[:original] = { var => diff.first }
            res[:new]      = { var => diff.last }
          end
        end
        res
      end
    end
  end
end

<commit_msg>Get rid of as_xml divergence in Difference<commit_after>module LLT
  class Diff::Parser
    class Difference
      include HashContainable

      attr_accessor :lemma, :postag, :head, :relation

      def to_xml
        grouped_differences.map { |type, val| "<#{type} #{to_xml_attrs(val)}/>" }.join
      end

      DIFFERENCES = %i{ lemma postag head relation }
      def grouped_differences
        res = { original: {}, new: {} }
        DIFFERENCES.each do |var|
          if diff = send(var)
            res[:original] = { var => diff.first }
            res[:new]      = { var => diff.last }
          end
        end
        res
      end
    end
  end
end


{'fraction_non_alphanumeric': 0.10416666666666667, 'fraction_numerical': 0.0, 'mean_word_length': 1.8256302521008403, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 7}, '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': '799082', 'n_tokens_mistral': 432, 'n_tokens_neox': 416, 'n_words': 114}