megagonlabs/bunkai

View on GitHub

Showing 55 of 55 total issues

Function convert_examples_to_features has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

def convert_examples_to_features(
    examples: List[InputExample],
    label_list: List[str],
    max_seq_length: int,
    tokenizer: JanomeSubwordsTokenizer,
Severity: Minor
Found in bunkai/third/utils_ner.py - About 4 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

File utils_ner.py has 340 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# mypy: ignore-errors
# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
#
Severity: Minor
Found in bunkai/third/utils_ner.py - About 4 hrs to fix

    Function get_sentence has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_sentence(node) -> typing.Iterator[str]:
        if node.tag == "sentence":
            yield bunkai.constant.METACHAR_SENTENCE_BOUNDARY
        for luw in node:
            if luw.tag == "webBr":
    Severity: Minor
    Found in bunkai/experiment/convert/bccwj.py - About 3 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 replace_parentheses_no1 has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def replace_parentheses_no1(self, original_text: str, split_points: List[SpanAnnotation]) -> List[SpanAnnotation]:
            """
            括弧内に次の文字列があった場合は、括弧及び括弧内の文字列を一文とする.
    
            例:  ̃ (近日中には冷房に切り替わる予定です。) ̃ 1 時間飲み放題(カクテル各種! ! )はお勧め.
    Severity: Minor
    Found in bunkai/algorithm/tsunoda_sbd/annotator/replace_parentheses.py - About 3 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 run has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def run(
        annotator,
        _text: str,
        ma: bool = False,
    ) -> typing.Iterator[str]:
    Severity: Minor
    Found in bunkai/cli.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 main has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def main() -> None:
        opts = get_opts()
    
        targets: typing.List[typing.Tuple[str, Path]] = [("__", opts.input)]
        if opts.input.is_dir():
    Severity: Minor
    Found in bunkai/experiment/statics.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 count has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def count(path: Path, outf: typing.IO, show: bool = False) -> Statics:
        st = Statics()
        with path.open() as inf:
            for doc in inf:
                text = doc[:-1]
    Severity: Minor
    Found in bunkai/experiment/statics.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

    File run_ner.py has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # mypy: ignore-errors
    # coding=utf-8
    # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
    # Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
    #
    Severity: Minor
    Found in bunkai/third/run_ner.py - About 2 hrs to fix

      Function main has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      def main() -> None:
          opts = get_opts()
          if opts.input.is_dir():
              opts.output.mkdir(exist_ok=True, parents=True)
              targets = [n for n in opts.input.iterdir()]
      Severity: Minor
      Found in bunkai/experiment/convert/bccwj.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 convert_examples_to_features has 16 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def convert_examples_to_features(
      Severity: Major
      Found in bunkai/third/utils_ner.py - About 2 hrs to fix

        Function _split_long_text has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def _split_long_text(
                self, tokens: typing.List[str]
            ) -> typing.Tuple[typing.List[typing.List[str]], typing.List[typing.List[int]]]:
                """
                Split documents(tokens) into sub-documents(tokens).
        Severity: Minor
        Found in bunkai/algorithm/lbd/predict.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 read_examples_from_file has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def read_examples_from_file(data_dir, mode: Union[Split, str]) -> List[InputExample]:
            if isinstance(mode, Split):
                mode = mode.value
            file_path = os.path.join(data_dir, f"{mode}.txt")
            guid_index = 1
        Severity: Minor
        Found in bunkai/third/utils_ner.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 get_bo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_bo(text: str, lbonly: bool) -> typing.List[str]:
            """Get a list of BIO sequence from input text."""
            assert METACHAR_SENTENCE_BOUNDARY + METACHAR_SENTENCE_BOUNDARY not in text
            assert not text.startswith(METACHAR_SENTENCE_BOUNDARY)
            ret: typing.List[str] = []
        Severity: Minor
        Found in bunkai/experiment/evaluate.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 replace_parentheses_no2 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def replace_parentheses_no2(self, original_text: str, split_points: List[SpanAnnotation]) -> List[SpanAnnotation]:
                """
                括弧内に、括弧の扱い(1)の文字列ではない基本分割文字列が現れた場合は、二回以上登場した際に限り分割点を付与する.
        
                要するに、括弧内で文境界付与を与えるということ.
        Severity: Minor
        Found in bunkai/algorithm/tsunoda_sbd/annotator/replace_parentheses.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 __init__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

                def __init__(
                    self,
                    data_dir: str,
                    tokenizer: PreTrainedTokenizer,
                    labels: List[str],
        Severity: Minor
        Found in bunkai/third/utils_ner.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 main has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def main() -> None:
            opts = get_opts()
        
            if opts.version:
                print(f"Bunkai {__version__}")
        Severity: Minor
        Found in bunkai/cli.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 main has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def main() -> None:
            opts = get_opts()
        
            if opts.split:
                lines = opts.input.readlines()
        Severity: Minor
        Found in bunkai/algorithm/lbd/corpus.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 __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in bunkai/algorithm/lbd/custom_tokenizers.py - About 1 hr to fix

          Function tokenize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def tokenize(self, text: typing.Union[str, typing.List[str]]) -> typing.List[str]:
                  if isinstance(text, str):
                      morphemes = self.janome_tokenizer.tokenize(text)
                  elif isinstance(text, list) and all([isinstance(t, str) for t in text]):
                      morphemes = text
          Severity: Minor
          Found in bunkai/algorithm/lbd/custom_tokenizers.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 count_char has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          def count_char(path: Path) -> typing.Iterator[str]:
              with path.open() as inf:
                  for doc in inf:
                      text = doc[:-1]
                      tokens = annotation2spans(text)
          Severity: Minor
          Found in bunkai/experiment/statics.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

          Severity
          Category
          Status
          Source
          Language