You are viewing documentation for our open source project which is maintained by the community. If you want to get started building assistants with Rasa please check out our latest [documentation here](/content/docs/index.html).

#### bilou_prefix_from_tag [#](https://legacy-docs-oss.rasa.com/docs/rasa/2.x/reference/rasa/nlu/utils/bilou_utils/#bilou_prefix_from_tag "Direct link to heading")

```python
bilou_prefix_from_tag(tag: Text) -> Optional[Text]
```

Returns the BILOU prefix from the given tag.

**Arguments**:

- `tag` - the tag  
**Returns** - the BILOU prefix of the tag

#### tag_without_prefix [#](https://legacy-docs-oss.rasa.com/docs/rasa/2.x/reference/rasa/nlu/utils/bilou_utils/#tag_without_prefix "Direct link to heading")

```python
tag_without_prefix(tag: Text) -> Text
```

Remove the BILOU prefix from the given tag.

**Arguments**:

- `tag` - the tag  
**Returns** - the tag without the BILOU prefix

#### bilou_tags_to_ids [#](https://legacy-docs-oss.rasa.com/docs/rasa/2.x/reference/rasa/nlu/utils/bilou_utils/#bilou_tags_to_ids "Direct link to heading")

```python
bilou_tags_to_ids(message: "Message", tag_id_dict: Dict[Text,int], tag_name: Text = ENTITY_ATTRIBUTE_TYPE) -> List[int]
```

Maps the entity tags of the message to the ids of the provided dict.

**Arguments**:

- `message` - the message  
- `tag_id_dict` - mapping of tags to ids  
- `tag_name` - tag name of interest  
**Returns** - a list of tag ids

#### get_bilou_key_for_tag [#](https://legacy-docs-oss.rasa.com/docs/rasa/2.x/reference/rasa/nlu/utils/bilou_utils/#get_bilou_key_for_tag "Direct link to heading")

```python
get_bilou_key_for_tag(tag_name: Text) -> Text
```

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 [#](https://legacy-docs-oss.rasa.com/docs/rasa/2.x/reference/rasa/nlu/utils/bilou_utils/#build_tag_id_dict "Direct link to heading")

```python
build_tag_id_dict(training_data: "TrainingData", tag_name: Text = ENTITY_ATTRIBUTE_TYPE) -> Optional[Dict[Text,int]]
```

Create a mapping of unique tags to ids.

**Arguments**:

- `training_data` - the training data  
- `tag_name` - tag name of interest  
**Returns** - a mapping of tags to ids

#### apply_bilou_schema [#](https://legacy-docs-oss.rasa.com/docs/rasa/2.x/reference/rasa/nlu/utils/bilou_utils/#apply_bilou_schema "Direct link to heading")

```python
apply_bilou_schema(training_data: "TrainingData") -> None
```

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 [#](https://legacy-docs-oss.rasa.com/docs/rasa/2.x/reference/rasa/nlu/utils/bilou_utils/#apply_bilou_schema_to_message "Direct link to heading")

```python
apply_bilou_schema_to_message(message: "Message") -> None
```

Get a list of BILOU entity tags and set them on the given message.

**Arguments**:

- `message` - the message

#### map_message_entities [#](https://legacy-docs-oss.rasa.com/docs/rasa/2.x/reference/rasa/nlu/utils/bilou_utils/#map_message_entities "Direct link to heading")

```python
map_message_entities(message: "Message", attribute_key: Text = ENTITY_ATTRIBUTE_TYPE) -> List[Tuple[int,int, Text]]
```

Maps the entities of the given message to their start, end, and tag values.

**Arguments**:

- `message` - the message  
- `attribute_key` - key of tag value to use  
**Returns** - a list of start, end, and tag value tuples

#### bilou_tags_from_offsets [#](https://legacy-docs-oss.rasa.com/docs/rasa/2.x/reference/rasa/nlu/utils/bilou_utils/#bilou_tags_from_offsets "Direct link to heading")

```python
bilou_tags_from_offsets(tokens: List["Token"], entities: List[Tuple[int,int, Text]]) -> List[Text]
```

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 [#](https://legacy-docs-oss.rasa.com/docs/rasa/2.x/reference/rasa/nlu/utils/bilou_utils/#ensure_consistent_bilou_tagging "Direct link to heading")

```python
ensure_consistent_bilou_tagging(predicted_tags: List[Text], predicted_confidences: List[float]) -> Tuple[List[Text], List[float]]
```

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 tags  
- `predicted_confidences` - predicted confidences  
**Returns**:

List of tags.  
List of confidences.
