<commit_before>module Traver
  class TraverConstructor
    attr_reader :settings
    
    def initialize(settings)
      @settings = settings
    end
    
    def define_factory(factory_name, *options)
      parent_factory_name = nil
    
      if options.size == 1
        params = options.first
      elsif options.size == 2
        parent_factory_name, params = options
      end
    
      settings.define_factory(factory_name, parent_factory_name, params)
    end
    
    def create(options)
      options = { options => {} } if options.is_a?(Symbol)
      
      factory_name, params = *options.first
      
      object_creator = ObjectCreator.new(factory_name, params, settings)
      object_creator.create_object
    
      object_creator.object
    end
    
    def create_graph(options)
      options = { options => {} } if options.is_a?(Symbol)
      
      factory_name, params = *options.first
    
      graph_creator = GraphCreator.new(factory_name, params, settings)
      graph_creator.create_graph
    
      graph_creator.graph
    end
    
    def undefine_all_factories
      settings.undefine_all_factories
    end
  end
end<commit_msg>Extract option parsing methods for TraverConstructor<commit_after>module Traver
  class TraverConstructor
    attr_reader :settings
    
    def initialize(settings)
      @settings = settings
    end
    
    def define_factory(factory_name, *options)
      parent_factory_name, params = parse_factory_options(options)
    
      settings.define_factory(factory_name, parent_factory_name, params)
    end
    
    def create(options)
      factory_name, params = parse_create_options(options)
      
      object_creator = ObjectCreator.new(factory_name, params, settings)
      object_creator.create_object
    
      object_creator.object
    end
    
    def create_graph(options)
      factory_name, params = parse_create_options(options)
    
      graph_creator = GraphCreator.new(factory_name, params, settings)
      graph_creator.create_graph
    
      graph_creator.graph
    end
    
    def undefine_all_factories
      settings.undefine_all_factories
    end
    
    private
    
    def parse_factory_options(options)
      parent_factory_name = nil
    
      if options.size == 1
        params = options.first
      elsif options.size == 2
        parent_factory_name, params = options
      end
      
      [parent_factory_name, params]
    end
    
    def parse_create_options(options)
      options = { options => {} } if options.is_a?(Symbol)
      
      options.first
    end
  end
end
{'fraction_non_alphanumeric': 0.061795569374271275, 'fraction_numerical': 0.001554605518849592, 'mean_word_length': 2.4878048780487805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '2625203', 'n_tokens_mistral': 754, 'n_tokens_neox': 750, 'n_words': 153}