rasa/nlu/utils/bilou_utils.py
File bilou_utils.py
has 346 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import logging
import operator
from collections import defaultdict, Counter
from typing import List, Tuple, Text, Optional, Dict, Any, TYPE_CHECKING
Function ensure_consistent_bilou_tagging
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
def 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.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _add_bilou_tags_to_entities
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def _add_bilou_tags_to_entities(
bilou: List[Text],
entities: List[Tuple[int, int, Text]],
end_pos_to_token_idx: Dict[int, int],
start_pos_to_token_idx: Dict[int, int],
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _update_confidences
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _update_confidences(