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: :param remove_empty_lines: Whether to remove empty lines.
  :param remove_extra_whitespaces: Whether to remove extra whitespaces.
  :param remove_repeated_substrings: Whether to remove repeated substrings (headers/footers) from pages.
      Pages in the text need to be separated by form feed character "",
      which is supported by TextFileToDocument and AzureOCRDocumentConverter.
  :param remove_substrings: List of substrings to remove from the text.
  :param remove_regex: Regex to match and replace substrings by "".
docstr_tok: [":","param","remove_empty_lines",":","Whether","to","remove","empty","lines",".",":","param","remove_extra_whitespaces",":","Whether","to","remove","extra","whitespaces",".",":","param","remove_repeated_substrings",":","Whether","to","remove","repeated","substrings","(","headers\/footers",")","from","pages",".","Pages","in","the","text","need","to","be","separated","by","form","feed","character","``","''",",","which","is","supported","by","TextFileToDocument","and","AzureOCRDocumentConverter",".",":","param","remove_substrings",":","List","of","substrings","to","remove","from","the","text",".",":","param","remove_regex",":","Regex","to","match","and","replace","substrings","by","``","''","."]
code: def __init__(
      self,
      remove_empty_lines: bool = True,
      remove_extra_whitespaces: bool = True,
      remove_repeated_substrings: bool = False,
      remove_substrings: Optional[List[str]] = None,
      remove_regex: Optional[str] = None,
  ):
      """
      :param remove_empty_lines: Whether to remove empty lines.
      :param remove_extra_whitespaces: Whether to remove extra whitespaces.
      :param remove_repeated_substrings: Whether to remove repeated substrings (headers/footers) from pages.
          Pages in the text need to be separated by form feed character "\f",
          which is supported by TextFileToDocument and AzureOCRDocumentConverter.
      :param remove_substrings: List of substrings to remove from the text.
      :param remove_regex: Regex to match and replace substrings by "".
      """
  
      self.remove_empty_lines = remove_empty_lines
      self.remove_extra_whitespaces = remove_extra_whitespaces
      self.remove_repeated_substrings = remove_repeated_substrings
      self.remove_substrings = remove_substrings
      self.remove_regex = remove_regex
  
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 1 to create a new DocumentCleaner object  with example: obj = DocumentCleaner(remove_empty_lines, remove_extra_whitespaces, remove_repeated_substrings, remove_substrings, remove_regex)