class_docstr: Makes text documents more readable by removing extra whitespaces, empty lines, specified substrings, regexes, page headers and footers (in this order).
  This is useful for preparing the documents for further processing by LLMs.
  
  Example usage in an indexing pipeline:
  
  ```python
  document_store = InMemoryDocumentStore()
  p = Pipeline()
  p.add_component(instance=TextFileToDocument(), name="text_file_converter")
  p.add_component(instance=DocumentCleaner(), name="cleaner")
  p.add_component(instance=TextDocumentSplitter(split_by="sentence", split_length=1), name="splitter")
  p.add_component(instance=DocumentWriter(document_store=document_store), name="writer")
  p.connect("text_file_converter.documents", "cleaner.documents")
  p.connect("cleaner.documents", "splitter.documents")
  p.connect("splitter.documents", "writer.documents")
  ```
class_docstr_tok: ["Makes","text","documents","more","readable","by","removing","extra","whitespaces",",","empty","lines",",","specified","substrings",",","regexes",",","page","headers","and","footers","(","in","this","order",")",".","This","is","useful","for","preparing","the","documents","for","further","processing","by","LLMs",".","Example","usage","in","an","indexing","pipeline",":","``","`","python","document_store","=","InMemoryDocumentStore","(",")","p","=","Pipeline","(",")","p.add_component","(","instance=TextFileToDocument","(",")",",","name=","''","text_file_converter","''",")","p.add_component","(","instance=DocumentCleaner","(",")",",","name=","''","cleaner","''",")","p.add_component","(","instance=TextDocumentSplitter","(","split_by=","''","sentence","''",",","split_length=1",")",",","name=","''","splitter","''",")","p.add_component","(","instance=DocumentWriter","(","document_store=document_store",")",",","name=","''","writer","''",")","p.connect","(","``","text_file_converter.documents","''",",","``","cleaner.documents","''",")","p.connect","(","``","cleaner.documents","''",",","``","splitter.documents","''",")","p.connect","(","``","splitter.documents","''",",","``","writer.documents","''",")","``","`"]
docstr: Find the longest common ngram across a list of text sequences (e.g. start of pages).
  Considering all ngram lengths between the minimum and maximum length. Helpful for finding footers, headers etc.
  Empty sequences are ignored.
  
  :param sequences: The list of strings that shall be searched for common n_grams.
  :param max_ngram: The maximum length of ngram to consider.
  :param min_ngram: The minimum length of ngram to consider.
  :return: The longest ngram that all sequences have in common.
docstr_tok: ["Find","the","longest","common","ngram","across","a","list","of","text","sequences","(","e.g",".","start","of","pages",")",".","Considering","all","ngram","lengths","between","the","minimum","and","maximum","length",".","Helpful","for","finding","footers",",","headers","etc",".","Empty","sequences","are","ignored",".",":","param","sequences",":","The","list","of","strings","that","shall","be","searched","for","common","n_grams",".",":","param","max_ngram",":","The","maximum","length","of","ngram","to","consider",".",":","param","min_ngram",":","The","minimum","length","of","ngram","to","consider",".",":","return",":","The","longest","ngram","that","all","sequences","have","in","common","."]
code: def _find_longest_common_ngram(
      self,
      sequences: List[str],
      min_ngram: int = 3,
      max_ngram: int = 30,
  ) -> str:
      """
      Find the longest common ngram across a list of text sequences (e.g. start of pages).
      Considering all ngram lengths between the minimum and maximum length. Helpful for finding footers, headers etc.
      Empty sequences are ignored.
  
      :param sequences: The list of strings that shall be searched for common n_grams.
      :param max_ngram: The maximum length of ngram to consider.
      :param min_ngram: The minimum length of ngram to consider.
      :return: The longest ngram that all sequences have in common.
      """
      sequences = [s for s in sequences if s]  # filter empty sequences
      if not sequences:
          return ""
      seqs_ngrams = map(
          partial(
              self._allngram, min_ngram=min_ngram, max_ngram=max_ngram
          ),
          sequences,
      )
      intersection = reduce(set.intersection, seqs_ngrams)
  
      longest = max(intersection, key=len, default="")
      return longest if longest.strip() else ""
  
file_path: haystack/haystack/components/preprocessors/document_cleaner.py
imports: import logging
  import re
  from copy import deepcopy
  from functools import partial, reduce
  from itertools import chain
  from typing import Generator, List, Optional, Set
  from haystack import Document, component
label_desc: Use image node_id 11 for calling the DocumentCleaner obj's underlying member method code with example usage: obj._find_longest_common_ngram(sequences, min_ngram, max_ngram) and returns: unknown, str