Sha256: cf60bebe26d462e3056ee0e7284e8f2fecba8a232e55e0c6a89b2cf70b23e528

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require_relative 'directory_loader'
require_relative '../ai/concept_ai'
require_relative '../data/world'

module InputLoader
  ##
  # Load input data from every input directory
  # @param inputdirs (Array)
  def self.load(inputdirs, internet = true)
    data = { concepts: [], codes: [], world: nil,
             concepts_ai: [], codes_ai: [] }
    inputdirs.each do |dirname|
      temp = DirectoryLoader.load(dirname)
      data[:concepts] += temp[:concepts]
      data[:codes] += temp[:codes]
    end
    create_questions(data, internet)
  end

  private_class_method def self.create_questions(data, internet)
    # Create World data
    # * Calculate concept neighbours
    # * TO-DO: Calculate code neighbours
    data[:world] = World.new(data[:concepts], internet)
    # Create ConceptAI data (ConceptAI = concept + questions)
    data[:concepts].each do |concept|
      data[:concepts_ai] << ConceptAI.new(concept, data[:world])
    end
    # Create CodeAI data (CodeAI = code + questions)
    data[:codes].each do |code|
      data[:codes_ai] << CodeAIFactory.get(code)
    end
    data
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
asker-tool-2.5.9 lib/asker/loader/input_loader.rb
asker-tool-2.5.8 lib/asker/loader/input_loader.rb