File count_vectors_featurizer.py
has 636 lines of code (exceeds 250 allowed). Consider refactoring. Open
from __future__ import annotations
import logging
import re
import scipy.sparse
from typing import Any, Dict, List, Optional, Text, Tuple, Set, Type
Function _check_OOV_present
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _check_OOV_present(self, all_tokens: List[List[Text]], attribute: Text) -> None:
"""Check if an OOV word is present."""
if not self.OOV_token or self.OOV_words or not all_tokens:
return
- 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 _replace_with_oov_token
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _replace_with_oov_token(
self, tokens: List[Text], attribute: Text
) -> List[Text]:
"""Replace OOV words with OOV token."""
if self.OOV_token and self.analyzer == "word":
- 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
def __init__(
Function load
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def load(
Function _check_analyzer
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _check_analyzer(self) -> None:
if self.analyzer != "word":
if self.OOV_token is not None:
logger.warning(
"Analyzer is set to character, "
- 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 _merge_new_vocabulary_tokens
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _merge_new_vocabulary_tokens(
self, existing_vocabulary: Dict[Text, int], vocabulary: Set[Text]
) -> None:
"""Merges new vocabulary tokens with the existing vocabulary.
- 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"