code: def detect_pattern_format(pattern_filename, encoding, on_word_boundaries):
      '''
      Automatically detects the pattern file format, and determines
      whether the Aho-Corasick string matching should pay attention to
      word boundaries or not.
  
      Arguments:
      - `pattern_filename`:
      - `encoding`:
      - `on_word_boundaries`:
      '''
      tsv = True
      boundaries = on_word_boundaries
      with open_file(pattern_filename) as input_file:
          for line in input_file:
              line = line.decode(encoding)
              if line.count('\t') != 1:
                  tsv = False
              if '\\b' in line:
                  boundaries = True
              if boundaries and not tsv:
                  break
      return tsv, boundarief detect_pattern_format(pattern_filename, encoding, on_word_boundaries):
      '''
      Automatically detects the pattern file format, and determines
      whether the Aho-Corasick string matching should pay attention to
      word boundaries or not.
  
      Arguments:
      - `pattern_filename`:
      - `encoding`:
      - `on_word_boundaries`:
      '''
      tsv = True
      boundaries = on_word_boundaries
      with open_file(pattern_filename) as input_file:
          for line in input_file:
              line = line.decode(encoding)
              if line.count('\t') != 1:
                  tsv = False
              if '\\b' in line:
                  boundaries = True
              if boundaries and not tsv:
                  break
      return tsv, boundaries
docs: Automatically detects the pattern file format, and determines
      whether the Aho-Corasick string matching should pay attention to
      word boundaries or not.
  
      Arguments:
      - `pattern_filename`:
      - `encoding`:
      - `on_word_boundaries`: