rasa/nlu/utils/bilou_utils.py

Summary

Maintainability
C
1 day
Test Coverage
A
97%

File bilou_utils.py has 346 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import operator
from collections import defaultdict, Counter
from typing import List, Tuple, Text, Optional, Dict, Any, TYPE_CHECKING

Severity: Minor
Found in rasa/nlu/utils/bilou_utils.py - About 4 hrs to fix

    Function ensure_consistent_bilou_tagging has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    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.
    
    
    Severity: Minor
    Found in rasa/nlu/utils/bilou_utils.py - About 1 hr to fix

    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

    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],
    Severity: Minor
    Found in rasa/nlu/utils/bilou_utils.py - About 1 hr to fix

    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

    def _update_confidences(
    Severity: Minor
    Found in rasa/nlu/utils/bilou_utils.py - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status