rasa/nlu/extractors/crf_entity_extractor.py
File crf_entity_extractor.py
has 522 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
from __future__ import annotations
from collections import OrderedDict
from enum import Enum
import logging
Function _create_features_for_token
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
Open
def _create_features_for_token(
self,
crf_tokens: List[CRFToken],
token_idx: int,
half_window_size: 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 __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Avoid deeply nested control flow statements. Open
Open
for pattern_name, matched in regex_patterns.items():
token_features[
f"{prefix}:{feature}:{pattern_name}"
] = matched
else:
Function _create_features_for_token
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _create_features_for_token(
Function load
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def load(
Function _update_crf_order
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
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:
- 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"