<commit_before>module HMachine
  module Pattern
    module TypeValue
      extend HMachine
      
      search do |doc| 
        doc.css('.type').reject {|type| type.parent.matches?('.type') }
      end
      
      extract do |node|
        if found_in?(node)
          element = find_in(node)
          types = element.collect {|type| HMachine.normalize Pattern::ValueClass.extract_from(type.unlink) }
          type = (types.length == 1) ? types.first : types
          {type => Pattern::ValueClass.extract_from(node)}
        else
          Pattern::ValueClass.extract_from(node)
        end
      end
      
    end
  end
end<commit_msg>TypeValue tries to get URL values first<commit_after>module HMachine
  module Pattern
    module TypeValue
      extend HMachine
      
      search do |doc| 
        doc.css('.type').reject {|type| type.parent.matches?('.type') }
      end
      
      extract do |node|
        if found_in?(node)
          element = find_in(node)
          types = element.collect {|type| HMachine.normalize Pattern::ValueClass.extract_from(type.unlink) }
          type = (types.length == 1) ? types.first : types
          {type => get_value(node)}
        else
          get_value(node)
        end
      end
      
      def self.get_value(node)
        if Pattern::URL.valid?(node)
          Pattern::URL.extract_from(node)
        else
          Pattern::ValueClass.extract_from(node)
        end
      end
      
    end
  end
end
{'fraction_non_alphanumeric': 0.10170648464163823, 'fraction_numerical': 0.0013651877133105802, 'mean_word_length': 1.937875751503006, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7568271', 'n_tokens_mistral': 428, 'n_tokens_neox': 426, 'n_words': 96}