Class: NluTools::Test
- Inherits:
-
Thor
- Object
- Thor
- NluTools::Test
- Defined in:
- lib/nlu_tools/cli/test.rb
Overview
The subcommand for test
Instance Method Summary collapse
Instance Method Details
#dialogflow ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/nlu_tools/cli/test.rb', line 40 def dialogflow unless File.exist?([:file]) puts "File #{[:file]} does not exist" exit(1) end intents = JSON.parse(File.read([:file])) schema = Pathname.new('schema/nlu_testing_data.json') schemer = JSONSchemer.schema(schema) if schemer.valid?(intents) na = NluAdapter.new(:Dialogflow, project_id: [:project_id], session_id: 'SESSION1') new_intents = {} intents['testing_data'].each do |intent| new_intents[intent['intent']] = intent['utterences'] end run_tests(na, new_intents, [:output_file], [:output_type]) else puts "Testing data is not in valid format\nPlease check data/simple_test.json for reference" exit(1) end end |
#lex ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/nlu_tools/cli/test.rb', line 100 def lex unless File.exist?([:file]) puts "File #{[:file]} does not exist" exit(1) end intents = JSON.parse(File.read([:file])) schema = Pathname.new('schema/nlu_testing_data.json') schemer = JSONSchemer.schema(schema) if schemer.valid?(intents) na = NluAdapter.new(:Lex, bot_name: [:botname], bot_alias: 'BotAlias', user_id: 'user-1') new_intents = {} intents['testing_data'].each do |intent| intent_name = intent['intent'].gsub('-', '_') new_intents[intent_name] = intent['utterences'] end run_tests(na, new_intents, [:output_file], [:output_type]) else puts "Testing data is not in valid format\nPlease check data/simple_test.json for reference" exit(1) end end |