Skip to content

Commit 1b8da63

Browse files
committed
return test for regex
1 parent 5f0c565 commit 1b8da63

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/modules/test_regex.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pytest
2+
3+
from autointent.modules import Regex
4+
from autointent.schemas import Intent
5+
6+
7+
@pytest.mark.parametrize(
8+
("partial_match", "expected_predictions"),
9+
[(".*", [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1]]), ("frozen", [[0], [0], [0], [0], [0, 1]])],
10+
)
11+
def test_base_regex(partial_match, expected_predictions):
12+
train_data = [
13+
Intent(id=0, name="accept_reservations", regex_full_match=[".*"], regex_partial_match=[".*"]),
14+
Intent(id=1, name="account_blocked", regex_partial_match=[partial_match]),
15+
]
16+
17+
matcher = Regex()
18+
matcher.fit(train_data)
19+
20+
test_data = [
21+
"why is there a hold on my american saving bank account",
22+
"i am nost sure why my account is blocked",
23+
"why is there a hold on my capital one checking account",
24+
"i think my account is blocked but i do not know the reason",
25+
"can you tell me why is my bank account frozen",
26+
]
27+
predictions = matcher.predict(test_data)
28+
assert predictions == expected_predictions
29+
30+
predictions, metadata = matcher.predict_with_metadata(test_data)
31+
assert len(predictions) == len(test_data) == len(metadata)
32+
33+
assert "partial_matches" in metadata[0]
34+
assert "full_matches" in metadata[0]

0 commit comments

Comments
 (0)