Esempio n. 1
0
    def test_should_load_from_dir_and_parse(self):
        # Given
        engine = NLUEngine(engine_dir=BEVERAGE_ENGINE_DIR)

        # When
        res = engine.parse("Make me two cups of coffee please")

        # Then
        self.assertEqual("MakeCoffee", res["intent"]["intentName"])
Esempio n. 2
0
    def test_should_load_from_zip_and_parse(self):
        # Given
        engine = NLUEngine(engine_bytes=SAMPLE_ENGINE_ZIP_BYTES)

        # Then
        res = engine.parse("Make me two cups of coffee please")

        # Then
        self.assertEqual("MakeCoffee", res["intent"]["intentName"])
    def test_should_load_from_zip_and_parse(self):
        # Given
        engine = NLUEngine(data_zip=SAMPLE_ASSISTANT_ZIP)

        # Then
        res = engine.parse("Make me two cups of coffee please")

        # Then
        self.assertEqual("MakeCoffee", res["intent"]["intentName"])
Esempio n. 4
0
    def test_should_parse_with_blacklist(self):
        # Given
        engine = NLUEngine(engine_bytes=BEVERAGE_ENGINE_ZIP_BYTES)

        # Then
        res = engine.parse("Make me two cups of coffee please",
                           intents_blacklist=["MakeCoffee"])

        # Then
        self.assertEqual("MakeTea", res["intent"]["intentName"])
Esempio n. 5
0
    def test_should_parse_with_intents_alternatives(self):
        # Given
        engine = NLUEngine(engine_bytes=BEVERAGE_ENGINE_ZIP_BYTES)

        # Then
        res = engine.parse("Make me two cups of coffee please",
                           intents_alternatives=1)

        # Then
        self.assertEqual("MakeCoffee", res["intent"]["intentName"])
        self.assertEqual(1, len(res["alternatives"]))
        self.assertEqual("MakeTea",
                         res["alternatives"][0]["intent"]["intentName"])
Esempio n. 6
0
    def test_should_parse_with_slots_alternatives(self):
        # Given
        engine = NLUEngine(engine_dir=GAME_ENGINE_DIR)

        # When
        result = engine.parse("I want to play to invader",
                              slots_alternatives=2)
        result["intent"]["confidenceScore"] = 0.8

        # 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",
        }]
        expected_result = {
            "input": "I want to play to invader",
            "intent": {
                "intentName": "PlayGame",
                "confidenceScore": 0.8
            },
            "slots": expected_slots,
            "alternatives": [],
        }
        self.assertEqual(expected_result, result)
    def test_should_load_with_zip_and_parse(self):
        # Given
        engine = NLUEngine(data_zip=SAMPLE_ASSISTANT_ZIP)

        # When/Then
        engine.parse("Make me two cups of coffee please")