Repository: RasaHQ/rasa
Pull request: Update default syntax for use_entities
**Proposed changes**:
Fixes #3842 

**Status (please check what you already did)**:
- [x] made PR ready for code review
- [x] added some tests for the functionality
- [x] updated the documentation
- [ ] updated the changelog
- [ ] reformat files using `black` (please check [Readme](https://github.com/RasaHQ/rasa_nlu#code-style) for instructions)


Problem statement:
domain entity featurization dump format
Reading a domain with
```
intents:
  - intent1:
    use_entities: False
```

currently leads to a dump format (if domain is persisted) which is a bit confusing

```
intents:
- intent1:
  use_entities: []
  ignore_entities: []
```

Ric also said:
> I'm not sure because in the docs and examples we give use_entities: None or use_entities: False. So I think to preserve that syntax we should dump use_entities: False in the case of an empty list. but that too is a rasa code change

We should check if we adapt the docs / code.

Hints from issue discussion:
But as far as I can see there is no issue with the `[]` for the value of `use_entities` right? I think we should change the documentation to use `[]` instead of `false`
@akelad Do we also change the schema definitions for `use_entities` to reflect the recommended usage?

Commit message: Include ignore_entities in domain schema

Patch to review:
diff --git a/data/test_domains/default_unfeaturized_entities.yml b/data/test_domains/default_unfeaturized_entities.yml
index 60e43c5b55f3..609227708d07 100644
--- a/data/test_domains/default_unfeaturized_entities.yml
+++ b/data/test_domains/default_unfeaturized_entities.yml
@@ -4,6 +4,7 @@ intents:
  - goodbye: {use_entities: None}
  - thank: {use_entities: False}
  - ask: {use_entities: True}
+ - why: {use_entities: []}
 
 entities:
  - name
diff --git a/data/test_stories/stories_unfeaturized_entities.md b/data/test_stories/stories_unfeaturized_entities.md
index 8af093ac2631..b3199c423baf 100644
--- a/data/test_stories/stories_unfeaturized_entities.md
+++ b/data/test_stories/stories_unfeaturized_entities.md
@@ -13,3 +13,5 @@
     - utter_default
 * ask{"name": "Peter", "unrelated_recognized_entity": "whatever", "other": "foo"}
     - utter_default
+* why{"name": "Peter", "unrelated_reognized_entity": "whatever", "other": "foo"}
+	- utter_default
diff --git a/docs/core/domains.rst b/docs/core/domains.rst
index 605223a176a2..ffe0515ae480 100644
--- a/docs/core/domains.rst
+++ b/docs/core/domains.rst
@@ -273,14 +273,14 @@ Ignoring entities for certain intents
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 If you want all entities to be ignored for certain intents, you can
-add the ``use_entities: None`` parameter to the intent in your domain
+add the ``use_entities: []`` parameter to the intent in your domain
 file like this:
 
 .. code-block:: yaml
 
   intents:
     - greet:
-        use_entities: None
+        use_entities: []
 
 To ignore some entities or explicitly take only certain entities
 into account you can use this syntax:
diff --git a/examples/formbot/domain.yml b/examples/formbot/domain.yml
index ab133a9b794d..f2387a64488d 100644
--- a/examples/formbot/domain.yml
+++ b/examples/formbot/domain.yml
@@ -1,8 +1,8 @@
 intents:
   - request_restaurant:
-      use_entities: false
+      use_entities: []
   - chitchat:
-      use_entities: false
+      use_entities: []
   - inform
   - affirm
   - deny
diff --git a/rasa/core/schemas/domain.yml b/rasa/core/schemas/domain.yml
index 1d0a2ed83306..bd7845b42f22 100644
--- a/rasa/core/schemas/domain.yml
+++ b/rasa/core/schemas/domain.yml
@@ -7,6 +7,8 @@ mapping:
       mapping:
         use_entities:
           type: "bool"
+        ignore_entities:
+          type: "bool"
       allowempty: True
     - type: "str"
   entities:
diff --git a/tests/core/test_domain.py b/tests/core/test_domain.py
index f888d290099a..909e94af7b7f 100644
--- a/tests/core/test_domain.py
+++ b/tests/core/test_domain.py
@@ -128,6 +128,8 @@ async def test_create_train_data_unfeaturized_entities():
 
     assert hashed == [
         "[{}]",
+        '[{"intent_why": 1.0, "prev_utter_default": 1.0}]',
+        '[{"intent_why": 1.0, "prev_action_listen": 1.0}]',
         '[{"intent_thank": 1.0, "prev_utter_default": 1.0}]',
         '[{"intent_thank": 1.0, "prev_action_listen": 1.0}]',
         '[{"intent_greet": 1.0, "prev_utter_greet": 1.0}]',


Code review comments:
diff_hunk: @@ -7,6 +7,8 @@ mapping:
       mapping:
         use_entities:
           type: "bool"
path: rasa/core/schemas/domain.yml
text: @user1:
both `use_entities` and `ignore_entities` can also be lists, can't they?

@author:
I couldn't find a type for list (the ones that look like `[...]`; their list is a multiline thing). I guess we could use a regex, but felt that would be overly complicated. This is the list of types they offer - https://pykwalify.readthedocs.io/en/unstable/validation-rules.html

@user1:
Mhm, should be `sequence` or `seq` 

@author:
Yeah, that's what I meant by "their list is a multiline thing". This is what they are referring to.
```md
# Data
- 'Foobar'
- 'Barfoo'
``` 

@user1:
thats the same thing :-) https://stackoverflow.com/questions/33989612/yaml-equivalent-of-array-of-objects-in-json

@author:
Ah, I guess that's settled then!

But we have a more fundamental problem - which is not being able to accommodate multiple data types. We could either do an `any` or choose any ONE single type. Can't do `OR` style types as far as what I read.

Guess we have to write a custom validator for this.

@author:
Thought the custom validators might help, but according to [this](https://pykwalify.readthedocs.io/en/unstable/extensions.html), it appears you can only add more failure cases for the parsing (and not do things that'd make it more lenient).

@user1:
mhm, that's a shame. Thanks for digging into this! let's put `any` then :-)