class_docstr: This class can read Abbyy documents out of a directory
docstr: Start trying to read the data from the directory :var self.directory
  
  :return: a Data.Book class with all the readed data from :var self.directory
  :exception WrongFileStructureException: Is raised then files are missing in the directory
              (e.g.: no image file for an xml file which is named equally)
  :exception XMLParseError: Is raised then there are errors in a xml file
code: def read(self) -> Book:
      """
      Start trying to read the data from the directory :var self.directory
  
      :return: a Data.Book class with all the readed data from :var self.directory
      :exception WrongFileStructureException: Is raised then files are missing in the directory
                  (e.g.: no image file for an xml file which is named equally)
      :exception XMLParseError: Is raised then there are errors in a xml file
      """
  
      book = Book()
      toremove = []
  
      # Searching for the xml abbyy files and handling Errors in the data structure
      for i, (imgfile, xmlfile) in tqdm(
          enumerate(zip(self.imgfiles, self.xmlfiles)),
          desc="Loading abby files",
          total=len(self.imgfiles),
      ):
          if xmlfile:
              if not os.path.exists(xmlfile):
                  if not self.skip_invalid:
                      raise XMLParseError(
                          "The abbyy xml file {} does not exist".format(
                              xmlfile
                          )
                      )
                  else:
                      toremove.append(i)
                      continue
  
          if imgfile:
              if not os.path.exists(imgfile):
                  if not self.skip_invalid:
                      raise XMLParseError(
                          "The image file {} does not exist".format(
                              imgfile
                          )
                      )
                  else:
                      toremove.append(i)
                      continue
  
          try:
              book.pages += list(self.parseXMLfile(imgfile, xmlfile))
          except XMLParseError as e:
              logger.exception(e)
              if self.skip_invalid:
                  logger.warning(
                      "Exception during XMLParsing ignored. Skipping example."
                  )
                  toremove.append(i)
                  continue
              else:
                  raise e
  
      for i in reversed(toremove):
          del self.imgfiles[i]
          del self.xmlfiles[i]
  
      return book
  
file_path: calamari/calamari_ocr/ocr/dataset/datareader/abbyy/xml/reader.py
imports: import os
  from lxml import etree
  from .data import Book, Page, Block, Format, Line, Par, Rect
  from .exceptions import XMLParseError
  from tqdm import tqdm
  import logging
label_desc: Use image node_id 2 for calling the XMLReader obj's underlying member method code with example usage: obj.read() and returns: book