Skip to content

Commit 0dc87b0

Browse files
committed
add test
1 parent 6087cbb commit 0dc87b0

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

tests/core/test_evaluation.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import os
22
from pathlib import Path
3+
from typing import Any, Text, Dict
4+
5+
import pytest
36

47
import rasa.utils.io
58
from rasa.core.test import (
@@ -10,6 +13,7 @@
1013
CONFUSION_MATRIX_STORIES_FILE,
1114
REPORT_STORIES_FILE,
1215
SUCCESSFUL_STORIES_FILE,
16+
_clean_entity_results,
1317
)
1418
from rasa.core.policies.memoization import MemoizationPolicy
1519

@@ -165,3 +169,70 @@ async def test_end_to_evaluation_trips_circuit_breaker():
165169
story_evaluation.evaluation_store.action_predictions == circuit_trip_predicted
166170
)
167171
assert num_stories == 1
172+
173+
174+
@pytest.mark.parametrize(
175+
"text, entity, expected_entity",
176+
[
177+
(
178+
"The first one please.",
179+
{
180+
"extractor": "DucklingHTTPExtractor",
181+
"entity": "ordinal",
182+
"confidence": 0.87,
183+
"start": 4,
184+
"end": 9,
185+
"value": 1,
186+
},
187+
{
188+
"text": "The first one please.",
189+
"entity": "ordinal",
190+
"start": 4,
191+
"end": 9,
192+
"value": "1",
193+
},
194+
),
195+
(
196+
"The first one please.",
197+
{
198+
"extractor": "CRFEntityExtractor",
199+
"entity": "ordinal",
200+
"confidence": 0.87,
201+
"start": 4,
202+
"end": 9,
203+
"value": "1",
204+
},
205+
{
206+
"text": "The first one please.",
207+
"entity": "ordinal",
208+
"start": 4,
209+
"end": 9,
210+
"value": "1",
211+
},
212+
),
213+
(
214+
"Italian food",
215+
{
216+
"extractor": "DIETClassifier",
217+
"entity": "cuisine",
218+
"confidence": 0.99,
219+
"start": 0,
220+
"end": 7,
221+
"value": "Italian",
222+
},
223+
{
224+
"text": "Italian food",
225+
"entity": "cuisine",
226+
"start": 0,
227+
"end": 7,
228+
"value": "Italian",
229+
},
230+
),
231+
],
232+
)
233+
def test_event_has_proper_implementation(
234+
text: Text, entity: Dict[Text, Any], expected_entity: Dict[Text, Any]
235+
):
236+
actual_entities = _clean_entity_results(text, [entity])
237+
238+
assert actual_entities[0] == expected_entity

0 commit comments

Comments
 (0)