File aifdb_builder.py
has 373 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Defines Builders for creating DeepA2 datasets from AIFdb corpora."""
from __future__ import annotations
import dataclasses
Function split_nodeset_per_inference
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def split_nodeset_per_inference( # pylint: disable=too-many-locals, too-many-statements
examples: Dict[str, List]
) -> Dict[str, List]:
"""extracts individual inferences from nodesets, and splits nodesets accordingly"""
- 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 load_dataset
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def load_dataset(self) -> datasets.DatasetDict:
splits = self._aifdb_config.splits
# download and unpack corpora
aifdb_dir = Path(self._aifdb_config.cache_dir)
- 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 _read_textfile
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _read_textfile(textfile: Path) -> str:
"""tries to read text file"""
lines: List[str] = []
if textfile.exists():
for enc in ["utf8", "ascii", "windows-1252", "cp500"]:
- 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 produce_da2item
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def produce_da2item(self) -> None:
# we produce a single da2item per input only
record = self._product[0]
record.source_text = str(self.input.text)
if self.input.reasons:
- 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"