<commit_before>require "hashie"
require "money"

module Fletcher
  module Model
    class Base < ::Hashie::Mash         
      # Create a product object based on service
      #   Fletcher::Model::Base.generate(:amazon, "<html>...") # => #<Fletcher::Model::Amazon:0x...> 
      def self.generate(service = nil, data = nil)
        case service
        when :amazon
          model = Fletcher::Model::Amazon.new
        when :ebay
          model = Fletcher::Model::Ebay.new
        when :thinkgeek
          model = Fletcher::Model::Thinkgeek.new
        when :etsy
          model = Fletcher::Model::Etsy.new
        end
        
        model.parse(data)
        return model 
      end

      # Parse data and set object attributes    
      def parse(data)
        self.doc = data # save data for if user wants to access it later      
      end      
      
      # Parse a raw price string to get usable data
      #   model.parse_price("$5.00") # => #<Money cents:500 currency:USD>
      #   model.price.to_f # => 5.0<commit_msg>enable auto detection / generate method support<commit_after>require "hashie"
require "money"

module Fletcher
  module Model
    class Base < ::Hashie::Mash         
      # Create a product object based on service
      #   Fletcher::Model::Base.generate(:amazon, "<html>...") # => #<Fletcher::Model::Amazon:0x...> 
      def self.generate(service = nil, data = nil)
        case service
        when :amazon
          model = Fletcher::Model::Amazon.new
        when :ebay
          model = Fletcher::Model::Ebay.new
        when :thinkgeek
          model = Fletcher::Model::Thinkgeek.new
        when :etsy
          model = Fletcher::Model::Etsy.new
        when :googleshopping
          model = Fletcher::Model::Googleshopping.new
        end
        
        model.parse(data)
        return model 
      end

      # Parse data and set object attributes    
      def parse(data)
        self.doc = data # save data for if user wants to access it later      
      end      
      
      # Parse a raw price string to get usable data
      #   model.parse_price("$5.00") # => #<Money cents:500 currency:USD>
      #   model.price.to_f # => 5.0
{'fraction_non_alphanumeric': 0.10507080858839653, 'fraction_numerical': 0.008222932846048425, 'mean_word_length': 1.967479674796748, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '2822540', 'n_tokens_mistral': 671, 'n_tokens_neox': 613, 'n_words': 178}