Module: AI
Overview
Description: Method to be included into every ConceptAI instance.
-
make_questions: use AI to fill @questions Array
Instance Method Summary collapse
-
#exclude_questions ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength.
- #make_questions ⇒ Object
- #make_questions_stages_bsf(tab, list1, list2) ⇒ Object
- #make_questions_stages_di ⇒ Object
- #make_questions_stages_t(tab, list1, list2) ⇒ Object
-
#string_has_this_tags?(input, tags) ⇒ Boolean
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength.
Methods included from AI_calculate
#calculate_nearness_between_texts, #get_list1_and_list2_from, #reorder_list_with_row
Instance Method Details
#exclude_questions ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/asker/ai/ai.rb', line 51 def exclude_questions param = Application.instance.config['questions']['exclude'] return if param.nil? = param.split(',').each(&:strip!) input = { d: [], b: [], f: [], i: [], s: [], t: [] } output = { d: [], b: [], f: [], i: [], s: [], t: [] } @questions.each_pair do |key, qlist| output[key] = qlist.select { |q| (q.name, ) } input[key] = @questions[key] - output[key] end @questions = input @excluded_questions = output end |
#make_questions ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/asker/ai/ai.rb', line 11 def make_questions return unless process? make_questions_stages_di # Process every table of this concept tables.each do |tab| list1, list2 = get_list1_and_list2_from(tab) make_questions_stages_bsf(tab, list1, list2) make_questions_stages_t(tab, list1, list2) end # ------------------------------------------------------- # Exclude questions as is defined into config.ini params exclude_questions end |
#make_questions_stages_bsf(tab, list1, list2) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/asker/ai/ai.rb', line 31 def make_questions_stages_bsf(tab, list1, list2) # Stage B: process table to make match questions @questions[:b] += StageB.new(self).run(tab, list1, list2) # Stage S: process tables with sequences @questions[:s] += StageS.new(self).run(tab, list1, list2) # Stage F: process tables with only 1 field @questions[:f] += StageF.new(self).run(tab, list1, list2) end |
#make_questions_stages_di ⇒ Object
26 27 28 29 |
# File 'lib/asker/ai/ai.rb', line 26 def make_questions_stages_di @questions[:d] = StageD.new(self).run # Process every def{type=text} @questions[:i] = StageI.new(self).run # Process every def{type=image_url} end |
#make_questions_stages_t(tab, list1, list2) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/asker/ai/ai.rb', line 40 def make_questions_stages_t(tab, list1, list2) # Stage T: process_tableXfields list3 = list1 + list2 list1.each do |row| reorder_list_with_row(list3, row) @questions[:t] += StageT.new(self).run(tab, row, list3) end end |
#string_has_this_tags?(input, tags) ⇒ Boolean
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength
69 70 71 72 73 |
# File 'lib/asker/ai/ai.rb', line 69 def (input, ) flag = false .each { |e| flag = true if input.include? e } flag end |