Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove BILOU tag prefix from role and group labels #6577

Merged
merged 3 commits into from
Sep 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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