-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retrieve agent and user ids from JSON in
json_to_dialogues
(#225)
* Retrieve agent and user ids from JSON in `json_to_dialogues` Fixes #223 * Use list of ids for filtering * Fix version of websockets to solve error in CI Related to this issue: sanic-org/sanic#2733
- Loading branch information
Showing
5 changed files
with
58 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
-r pre_commit.txt | ||
scikit-learn >= 0.24 | ||
rasa >= 3.0.8 | ||
rasa >= 3.0.8 | ||
websockets<11.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,46 @@ | ||
"""Tests for the dialogue reader.""" | ||
|
||
from typing import List | ||
|
||
import pytest | ||
|
||
from dialoguekit.utils.dialogue_reader import json_to_dialogues | ||
|
||
|
||
def test_json_to_dialogues(): | ||
def test_json_to_dialogues() -> None: | ||
"""Tests reading of json dialogues.""" | ||
dialogues = json_to_dialogues( | ||
filepath="tests/data/annotated_dialogues.json", | ||
agent_id="TestAGENT", | ||
user_id="TestUSER", | ||
) | ||
assert len(dialogues) == 3 | ||
assert len(dialogues[0].utterances) > 0 | ||
assert dialogues[0].agent_id == "MovieBotTester" | ||
assert dialogues[0].user_id == "TEST03" | ||
assert dialogues[-1].agent_id == "Agent" | ||
assert dialogues[-1].user_id == "User" | ||
assert dialogues[0].utterances[0].participant == "USER" | ||
assert dialogues[0].utterances[1].participant == "AGENT" | ||
assert dialogues[0].utterances[0].intent.label == "DISCLOSE.NON-DISCLOSE" | ||
assert dialogues[0].utterances[1].intent.label == "INQUIRE.ELICIT" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"agent_ids, user_ids, expected_dialogue_count", | ||
[ | ||
(["MovieBotTester"], None, 1), | ||
(None, None, 3), | ||
(["TestAgent"], ["TestUser"], 0), | ||
(None, ["TEST03"], 1), | ||
(["MovieBotTester"], ["TEST03"], 1), | ||
], | ||
) | ||
def test_json_to_dialogues_filtered( | ||
agent_ids: List[str], user_ids: List[str], expected_dialogue_count: int | ||
) -> None: | ||
"""Tests reading of json dialogues with filtering parameters.""" | ||
dialogues = json_to_dialogues( | ||
filepath="tests/data/annotated_dialogues.json", | ||
agent_ids=agent_ids, | ||
user_ids=user_ids, | ||
) | ||
assert len(dialogues) == expected_dialogue_count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters