Showing 39 of 43 total issues
File model.py
has 360 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
# Автор: Гусев Илья
# Описание: Модель PoS-теггера на основе BiLSTM.
from typing import List, Tuple
Function __iter__
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def __iter__(self):
"""
Получение очередного батча.
: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 __get_lemma
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def __get_lemma(self, word: str, pos_tag: str, gram: str, word_forms=None,
enable_normalization: bool=True):
"""
Получить лемму.
- 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 evaluate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def evaluate(self, file_names, val_idx, train_config: TrainConfig, build_config: BuildModelConfig) -> None:
"""
Оценка на val выборке.
:param file_names: файлы выборки.
- 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 get_sample
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def get_sample(sentence: List[str],
language: str,
converter,
morph: MorphAnalyzer,
grammeme_vectorizer: GrammemeVectorizer,
- 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 train
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def train(file_names: List[str], train_config_path: str, build_config_path: str,
language: str, embeddings_path: str=None):
train_config = TrainConfig()
train_config.load(train_config_path)
if train_config.train_model_config_path is None:
- 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 convert_from_conllu
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def convert_from_conllu(input_filename, output_filename, with_forth_column=False, with_punct=True,
add_number=False):
with open(input_filename, "r", encoding='utf-8') as r, open(output_filename, "w", encoding='utf-8') as w:
i = 0
for line in r:
- 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 build
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def build(self, config: BuildModelConfig, word_embeddings=None):
"""
Описание модели.
:param config: конфиг модели.
- 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 get_char_model
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_char_model(
Function __normalize_for_gikrya
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def __normalize_for_gikrya(form):
"""
Поучение леммы по правилам, максимально близким к тем, которые в корпусе ГИКРЯ.
:param form: форма из pymorphy2.
- 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 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, language: str,
Function __init__
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self,
language="ru",
eval_model_config_path: str=None,
eval_model_weights_path: str=None,
gram_dict_input: str=None,
- 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 __build_vector
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def __build_vector(self, pos_tag: str, grammemes: List[str]) -> List[int]:
"""
Построение вектора по части речи и грамматическим значениям.
:param pos_tag: часть речи.
- 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 build
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build(self, config: BuildModelConfig, word_embeddings=None):
"""
Описание модели.
:param config: конфиг модели.
Function __init__
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(self):
self.use_gram = True
self.gram_hidden_size = 30
self.gram_dropout = 0.3
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self,
Function get_sample
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_sample(sentence: List[str],
Function load_train
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def load_train(self, config: BuildModelConfig, model_config_path: str=None, model_weights_path: str=None):
with open(model_config_path, "r", encoding='utf-8') as f:
if config.use_crf:
from keras_contrib.layers import CRF
custom_objects = {'ReversedLSTM': ReversedLSTM, 'CRF': CRF}
- 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 shrink_w2v
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def shrink_w2v(input_filename, border, output_filename, print_step=10000):
vocabulary_embeddings = dict()
all_count = 0
correct_count = 0
with open(input_filename, "r", encoding='utf-8', errors='ignore') as r:
- 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
Avoid deeply nested control flow statements. Open
for index, bucket in enumerate(self.buckets):
if self.bucket_borders[index][0] <= len(last_sentence) < self.bucket_borders[index][1]:
bucket.append(last_sentence)
if len(bucket) >= self.batch_size:
yield self.__to_tensor(bucket)