Function prepare
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def prepare(self, negative_multiplier=3.):
"""Constructs negative sampling and handling train/test differences."""
desc = ("prepare data for training"
if self.is_train else "prepare data for testing")
total_missed_entities = 0
- 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 process_word_list_and_spans_to_inputs
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def process_word_list_and_spans_to_inputs(self, sid, word_list, spans):
"""Constructs the fffner input with spans and types."""
tokenized_word_list = self.tokenize_word_list(word_list)
final_len = sum(len(x) for x in tokenized_word_list)
final_len = 2 + 3 + 2 + 3 + final_len # account for mask and brackets
- 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
File create_data.py
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright 2024 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Function bio_labels_to_spans
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def bio_labels_to_spans(self, bio_labels):
"""Gets labels to spans."""
spans = []
for i, label in enumerate(bio_labels):
if label.startswith("B-"):
- 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 process_to_input
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_to_input(self, input_ids, is_entity_token_pos,
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, words_path, labels_path, tokenizer, is_train,
Avoid deeply nested control flow statements. Open
if not self.is_train or ent_type != "O":
spans.append((i, j, "mask", ent_type))
else:
negative_spans.append((i, j, "mask", ent_type))
intersection_size = (is_token_entity_prefix[j + 1] -