def test_get_slots_should_fail_with_unknown_intent(self): # Given engine = NLUEngine(engine_bytes=BEVERAGE_ENGINE_ZIP_BYTES) # Then with self.assertRaises(ValueError) as cm: engine.get_slots("Make me two cups of coffee please", intent="my_intent") self.assertTrue("Unknown intent" in str(cm.exception))
def test_should_get_slots(self): # Given engine = NLUEngine(engine_bytes=SAMPLE_ENGINE_ZIP_BYTES) # Then slots = engine.get_slots("Make me two cups of coffee please", intent="MakeCoffee") # Then expected_slots = [{ "entity": "snips/number", "range": { "end": 11, "start": 8 }, "rawValue": "two", "slotName": "number_of_cups", "value": { "kind": "Number", "value": 2.0 } }] self.assertEqual(expected_slots, slots)
def test_should_get_slots_with_alternatives(self): # Given engine = NLUEngine(engine_dir=GAME_ENGINE_DIR) # When slots = engine.get_slots("I want to play to invader", intent="PlayGame", slots_alternatives=2) # Then expected_slots = [{ "rawValue": "invader", "value": { "kind": "Custom", "value": "Invader Attack 3" }, "alternatives": [ { "kind": "Custom", "value": "Invader War Demo" }, { "kind": "Custom", "value": "Space Invader Limited Edition" }, ], "range": { "start": 18, "end": 25 }, "slotName": "game", "entity": "game", }] self.assertEqual(expected_slots, slots)