Example #1
0
def test_contains_errors_should_work_when_errors_in_intent():
    # Given
    utterance_metrics = {
        "intent1": {
            "intent": {
                TRUE_POSITIVE: 5,
                FALSE_POSITIVE: 1,
                FALSE_NEGATIVE: 0
            },
            "slots": {
                "slot1": {
                    TRUE_POSITIVE: 3,
                    FALSE_POSITIVE: 0,
                    FALSE_NEGATIVE: 0
                }
            },
        },
        "intent2": {
            "intent": {
                TRUE_POSITIVE: 20,
                FALSE_POSITIVE: 0,
                FALSE_NEGATIVE: 0
            },
            "slots": {},
        },
    }

    # When
    res = contains_errors(utterance_metrics, True)

    # Then
    assert res
Example #2
0
def test_contains_errors_should_not_check_slots_when_specified():
    # Given
    utterance_metrics = {
        "intent1": {
            "intent": {
                TRUE_POSITIVE: 5,
                FALSE_POSITIVE: 0,
                FALSE_NEGATIVE: 0
            },
            "slots": {
                "slot1": {
                    TRUE_POSITIVE: 3,
                    FALSE_POSITIVE: 0,
                    FALSE_NEGATIVE: 0
                },
                "slot2": {
                    TRUE_POSITIVE: 3,
                    FALSE_POSITIVE: 0,
                    FALSE_NEGATIVE: 2
                },
            },
        }
    }

    # When
    check_slots = False
    res = contains_errors(utterance_metrics, check_slots)

    # Then
    assert not res
Example #3
0
    def test_contains_errors_should_work_when_no_errors(self):
        # Given
        utterance_metrics = {
            "intent1": {
                "intent": {
                    TRUE_POSITIVE: 5,
                    FALSE_POSITIVE: 0,
                    FALSE_NEGATIVE: 0
                },
                "slots": {
                    "slot1": {
                        TRUE_POSITIVE: 3,
                        FALSE_POSITIVE: 0,
                        FALSE_NEGATIVE: 0
                    },
                    "slot2": {
                        TRUE_POSITIVE: 3,
                        FALSE_POSITIVE: 0,
                        FALSE_NEGATIVE: 0
                    },
                }
            },
            "intent2": {
                "intent": {
                    TRUE_POSITIVE: 20,
                    FALSE_POSITIVE: 0,
                    FALSE_NEGATIVE: 0
                },
                "slots": {}
            }
        }

        # When
        res = contains_errors(utterance_metrics, True)

        # Then
        self.assertFalse(res)