IlyaGusev/rnnmorph

View on GitHub
rnnmorph/model.py

Summary

Maintainability
C
1 day
Test Coverage

File model.py has 360 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
# Автор: Гусев Илья
# Описание: Модель PoS-теггера на основе BiLSTM.

from typing import List, Tuple
Severity: Minor
Found in rnnmorph/model.py - About 4 hrs to fix

    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: файлы выборки.
    Severity: Minor
    Found in rnnmorph/model.py - About 2 hrs to fix

    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: конфиг модели.
    Severity: Minor
    Found in rnnmorph/model.py - About 1 hr to fix

    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: конфиг модели.
    Severity: Minor
    Found in rnnmorph/model.py - About 1 hr to fix

      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}
      Severity: Minor
      Found in rnnmorph/model.py - About 55 mins to fix

      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 prepare has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def prepare(self, gram_dump_path_input: str, gram_dump_path_output: str,
      Severity: Minor
      Found in rnnmorph/model.py - About 35 mins to fix

        Function predict_probabilities has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def predict_probabilities(self, sentences: List[List[str]], batch_size: int,
                                      build_config: BuildModelConfig) -> List[List[List[float]]]:
                """
                Предсказание полных PoS-тегов по предложению с вероятностями всех вариантов.
        
        
        Severity: Minor
        Found in rnnmorph/model.py - About 35 mins to fix

        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 prepare has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def prepare(self, gram_dump_path_input: str, gram_dump_path_output: str,
                        word_vocabulary_dump_path: str, char_set_dump_path: str,
                        file_names: List[str] = None) -> None:
                """
                Подготовка векторизатора грамматических значений и словаря слов по корпусу.
        Severity: Minor
        Found in rnnmorph/model.py - About 25 mins to fix

        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 count_samples has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def count_samples(file_names: List[str]):
                """
                Считает количество предложений в выборке.
        
                :param file_names: файлы выборки.
        Severity: Minor
        Found in rnnmorph/model.py - About 25 mins to fix

        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 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def train(self, file_names: List[str], train_config: TrainConfig, build_config: BuildModelConfig) -> None:
                np.random.seed(train_config.random_seed)
                sample_counter = self.count_samples(file_names)
                train_idx, val_idx = self.get_split(sample_counter, train_config.val_part)
                for big_epoch in range(train_config.epochs_num):
        Severity: Minor
        Found in rnnmorph/model.py - About 25 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status