Skip to content

Commit

Permalink
Merge 8eddfcb into 03c8e1d
Browse files Browse the repository at this point in the history
  • Loading branch information
wochinge committed Jul 18, 2019
2 parents 03c8e1d + 8eddfcb commit 1ad8147
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -25,6 +25,7 @@ Removed
Fixed
-----
- validation no longer throws an error during interactive learning
- fixed wrong cleaning of ``use_entities`` in case it was a list and not ``True``
- updated the server endpoint ``/model/parse`` to handle also messages with the intent prefix

[1.1.6] - 2019-07-12
Expand Down
3 changes: 2 additions & 1 deletion data/test_domains/default_unfeaturized_entities.yml
@@ -1,10 +1,11 @@
intents:
- greet: {use_entities: [name]}
- default: {ignore_entities : [unrelated_recognized_entity]}
- goodbye: {use_entities: None}
- goodbye: {use_entities: null}
- thank: {use_entities: False}
- ask: {use_entities: True}
- why: {use_entities: []}
- pure_intent

entities:
- name
Expand Down
4 changes: 2 additions & 2 deletions rasa/core/domain.py
Expand Up @@ -656,10 +656,10 @@ def cleaned_domain(self) -> Dict[Text, Any]:
domain_data = self.as_dict()
for idx, intent_info in enumerate(domain_data["intents"]):
for name, intent in intent_info.items():
if intent.get("use_entities"):
if intent.get("use_entities") is True:
intent.pop("use_entities")
if not intent.get("ignore_entities"):
intent.pop("ignore_entities")
intent.pop("ignore_entities", None)
if len(intent) == 0:
domain_data["intents"][idx] = name

Expand Down
30 changes: 29 additions & 1 deletion tests/core/test_domain.py
Expand Up @@ -3,7 +3,6 @@
import pytest
from _pytest.tmpdir import TempdirFactory

import rasa.utils.io
from rasa.core import training, utils
from rasa.core.domain import Domain, InvalidDomain
from rasa.core.featurizers import MaxHistoryTrackerFeaturizer
Expand Down Expand Up @@ -501,3 +500,32 @@ def test_load_on_invalid_domain():
# Currently just deprecated
# with pytest.raises(InvalidDomain):
# Domain.load("data/test_domains/missing_text_for_templates.yml")


def test_clean_domain():
domain_path = "data/test_domains/default_unfeaturized_entities.yml"
cleaned = Domain.load(domain_path).cleaned_domain()

expected = {
"intents": [
{"greet": {"use_entities": ["name"]}},
{"default": {"ignore_entities": ["unrelated_recognized_entity"]}},
{"goodbye": {"use_entities": []}},
{"thank": {"use_entities": []}},
"ask",
{"why": {"use_entities": []}},
"pure_intent",
],
"entities": ["name", "other", "unrelated_recognized_entity"],
"templates": {
"utter_greet": [{"text": "hey there!"}],
"utter_goodbye": [{"text": "goodbye :("}],
"utter_default": [{"text": "default message"}],
},
"actions": ["utter_default", "utter_goodbye", "utter_greet"],
}

expected = Domain.from_dict(expected)
actual = Domain.from_dict(cleaned)

assert hash(actual) == hash(expected)

0 comments on commit 1ad8147

Please sign in to comment.