rasa/nlu/extractors/crf_entity_extractor.py

Summary

Maintainability
D
1 day
Test Coverage
A
92%

File crf_entity_extractor.py has 522 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import annotations

from collections import OrderedDict
from enum import Enum
import logging
Severity: Major
Found in rasa/nlu/extractors/crf_entity_extractor.py - About 1 day to fix

    Function _create_features_for_token has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def _create_features_for_token(
            self,
            crf_tokens: List[CRFToken],
            token_idx: int,
            half_window_size: int,
    Severity: Minor
    Found in rasa/nlu/extractors/crf_entity_extractor.py - About 2 hrs 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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in rasa/nlu/extractors/crf_entity_extractor.py - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for pattern_name, matched in regex_patterns.items():
                                  token_features[
                                      f"{prefix}:{feature}:{pattern_name}"
                                  ] = matched
                          else:
      Severity: Major
      Found in rasa/nlu/extractors/crf_entity_extractor.py - About 45 mins to fix

        Function _create_features_for_token has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _create_features_for_token(
        Severity: Minor
        Found in rasa/nlu/extractors/crf_entity_extractor.py - About 45 mins to fix

          Function load has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def load(
          Severity: Minor
          Found in rasa/nlu/extractors/crf_entity_extractor.py - About 35 mins to fix

            Function _update_crf_order has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def _update_crf_order(self, training_data: TrainingData) -> None:
                    """Train only CRFs we actually have training data for."""
                    _crf_order = []
            
                    for tag_name in self.crf_order:
            Severity: Minor
            Found in rasa/nlu/extractors/crf_entity_extractor.py - About 25 mins 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

            There are no issues that match your filters.

            Category
            Status