rasa.nlu.utils.bilou_utils
bilou_prefix_from_tag
Returns the BILOU prefix from the given tag.
Arguments:
tag
- the tagReturns
- the BILOU prefix of the tag
tag_without_prefix
Remove the BILOU prefix from the given tag.
Arguments:
tag
- the tagReturns
- the tag without the BILOU prefix
bilou_tags_to_ids
Maps the entity tags of the message to the ids of the provided dict.
Arguments:
message
- the messagetag_id_dict
- mapping of tags to idstag_name
- tag name of interestReturns
- a list of tag ids
get_bilou_key_for_tag
Get the message key for the BILOU tagging format of the provided tag name.
Arguments:
tag_name
- the tag name
Returns:
the message key to store the BILOU tags
build_tag_id_dict
Create a mapping of unique tags to ids.
Arguments:
training_data
- the training datatag_name
- tag name of interestReturns
- a mapping of tags to ids
apply_bilou_schema
Get a list of BILOU entity tags and set them on the given messages.
Arguments:
training_data
- the training data
apply_bilou_schema_to_message
Get a list of BILOU entity tags and set them on the given message.
Arguments:
message
- the message
map_message_entities
Maps the entities of the given message to their start, end, and tag values.
Arguments:
message
- the messageattribute_key
- key of tag value to useReturns
- a list of start, end, and tag value tuples
bilou_tags_from_offsets
Creates BILOU tags for the given tokens and entities.
Arguments:
message
- The message object.tokens
- The list of tokens.entities
- The list of start, end, and tag tuples.missing
- The tag for missing entities.
Returns:
BILOU tags.
ensure_consistent_bilou_tagging
Ensure predicted tags follow the BILOU tagging schema.
We assume that starting B- tags are correct. Followed tags that belong to start tag but have a different entity type are updated considering also the confidence values of those tags. For example, B-a I-b L-a is updated to B-a I-a L-a and B-a I-a O is changed to B-a L-a.
Arguments:
predicted_tags
- predicted tagspredicted_confidences
- predicted confidences
Returns:
List of tags. List of confidences.