Skip to content

Commit

Permalink
Merge pull request #6577 from RasaHQ/role-group-bilou-tags
Browse files Browse the repository at this point in the history
Remove BILOU tag prefix from role and group labels
  • Loading branch information
rasabot authored Sep 7, 2020
2 parents a360b68 + a98deba commit 9c7ca51
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/6577.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove BILOU tag prefix from role and group labels when creating entities.
2 changes: 2 additions & 0 deletions rasa/nlu/extractors/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def convert_predictions_into_entities(
continue

current_group_tag = self.get_tag_for(tags, ENTITY_ATTRIBUTE_GROUP, idx)
current_group_tag = bilou_utils.tag_without_prefix(current_group_tag)
current_role_tag = self.get_tag_for(tags, ENTITY_ATTRIBUTE_ROLE, idx)
current_role_tag = bilou_utils.tag_without_prefix(current_role_tag)

group_or_role_changed = (
last_group_tag != current_group_tag or last_role_tag != current_role_tag
Expand Down
31 changes: 31 additions & 0 deletions tests/nlu/extractors/test_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,37 @@
},
],
),
(
"I am flying from San Fransisco to Amsterdam",
{
"entity": ["O", "O", "O", "O", "B-city", "L-city", "O", "U-city"],
"role": ["O", "O", "O", "O", "B-from", "L-from", "O", "U-to"],
},
{
"entity": [1.0, 1.0, 1.0, 1.0, 0.98, 0.78, 1.0, 0.89],
"role": [1.0, 1.0, 1.0, 1.0, 0.98, 0.78, 1.0, 0.89],
},
[
{
"entity": "city",
"start": 17,
"end": 30,
"value": "San Fransisco",
"role": "from",
"confidence_entity": 0.78,
"confidence_role": 0.78,
},
{
"entity": "city",
"start": 34,
"end": 43,
"value": "Amsterdam",
"role": "to",
"confidence_entity": 0.89,
"confidence_role": 0.89,
},
],
),
(
"I am flying from San Fransisco to Amsterdam",
{
Expand Down

0 comments on commit 9c7ca51

Please sign in to comment.