<commit_before>module HMachine
  module Pattern
    module ValueClass
      extend HMachine
      WIKI_URL = 'http://microformats.org/wiki/value-class-pattern'
      
      search do |element| 
        element.css('.value, .value-title[title]').reject {|val| val.parent.matches?('.value') }
      end
      
      validate {|value| value.matches?('.value, .value-title[title]') }
      
      extract do |node|
        if found_in?(node)
          values = get_values(node)
          normalize_values = values.collect { |val| DateTime.valid?(val) ? DateTime.iso8601(val) : val }.join
          DateTime.valid?(normalize_values) ? DateTime.extract_from(normalize_values) : normalize_values
        else
          node.content.strip
        end
      end
      
      def self.get_values(node)
        find_in(node).collect do |val|
          if (val.node_name.eql?('img') || val.node_name.eql?('area')) && val['alt']
            val['alt']
          elsif (Abbr.valid?(val) || val.matches?('.value-title'))
            val['title']
          else<commit_msg>ValueClass pattern falls back to Abbr pattern<commit_after>module HMachine
  module Pattern
    module ValueClass
      extend HMachine
      WIKI_URL = 'http://microformats.org/wiki/value-class-pattern'
      
      search do |element| 
        element.css('.value, .value-title[title]').reject {|val| val.parent.matches?('.value') }
      end
      
      validate {|value| value.matches?('.value, .value-title[title]') }
      
      extract do |node|
        if found_in?(node)
          values = get_values(node)
          normalize_values = values.collect { |val| DateTime.valid?(val) ? DateTime.iso8601(val) : val }.join
          DateTime.valid?(normalize_values) ? DateTime.extract_from(normalize_values) : normalize_values
        elsif Abbr.valid?(node)
          Abbr.extract_from(node)
        else
          node.content.strip
        end
      end
      
      def self.get_values(node)
        find_in(node).collect do |val|
          if (val.node_name.eql?('img') || val.node_name.eql?('area')) && val['alt']
            val['alt']
          elsif (Abbr.valid?(val) || val.matches?('.value-title'))
            val['title']
          else
{'fraction_non_alphanumeric': 0.1360759493670886, 'fraction_numerical': 0.003616636528028933, 'mean_word_length': 2.2640117994100293, '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': '5544658', 'n_tokens_mistral': 683, 'n_tokens_neox': 679, 'n_words': 124}