Skip to content

Commit

Permalink
Merge pull request #6714 from RasaHQ/bilou-tag-prefix
Browse files Browse the repository at this point in the history
Remove BILOU tag prefix from role and group labels
  • Loading branch information
tabergma authored Sep 21, 2020
2 parents 5612584 + 4bd4061 commit 0390605
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 @@ -405,7 +405,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 @@ -284,6 +284,37 @@ def test_clean_up_entities(
},
],
),
(
"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 0390605

Please sign in to comment.