Skip to content

Commit

Permalink
Merge pull request #5797 from RasaHQ/empty-role-group
Browse files Browse the repository at this point in the history
Don't set roles/groups to 'O'
  • Loading branch information
tabergma authored May 12, 2020
2 parents 507d63c + 4abccd6 commit 79cb399
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/5788.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't set roles and groups to ``O`` (nothing found) when constructing entities from model predictions.
4 changes: 2 additions & 2 deletions rasa/nlu/extractors/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,13 @@ def _create_new_entity(
ENTITY_ATTRIBUTE_TYPE
][idx]

if ENTITY_ATTRIBUTE_ROLE in tag_names:
if ENTITY_ATTRIBUTE_ROLE in tag_names and role_tag != NO_ENTITY_TAG:
entity[ENTITY_ATTRIBUTE_ROLE] = role_tag
if confidences is not None:
entity[ENTITY_ATTRIBUTE_CONFIDENCE_ROLE] = confidences[
ENTITY_ATTRIBUTE_ROLE
][idx]
if ENTITY_ATTRIBUTE_GROUP in tag_names:
if ENTITY_ATTRIBUTE_GROUP in tag_names and group_tag != NO_ENTITY_TAG:
entity[ENTITY_ATTRIBUTE_GROUP] = group_tag
if confidences is not None:
entity[ENTITY_ATTRIBUTE_CONFIDENCE_GROUP] = confidences[
Expand Down
6 changes: 6 additions & 0 deletions tests/nlu/extractors/test_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ def test_clean_up_entities(
},
],
),
(
"Amsterdam",
{"entity": ["city"], "role": ["O"], "group": ["O"]},
None,
[{"entity": "city", "start": 0, "end": 9, "value": "Amsterdam"}],
),
],
)
def test_convert_tags_to_entities(
Expand Down

0 comments on commit 79cb399

Please sign in to comment.