java.lang.Object
com.iqser.red.service.redaction.v1.server.model.document.nodes.Table
All Implemented Interfaces:
SemanticNode

public class Table extends Object implements SemanticNode
Represents a table within a document.
  • Constructor Details

    • Table

      public Table(Set<com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine> engines, List<Integer> treeId, com.iqser.red.service.redaction.v1.server.model.document.DocumentTree documentTree, int numberOfRows, int numberOfCols, com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock, Set<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> entities, Map<Page,Rectangle2D> bBoxCache)
  • Method Details

    • getBBox

      public Map<Page,Rectangle2D> getBBox()
      Description copied from interface: SemanticNode
      If this Node is a Leaf it will calculate the boundingBox of its LeafTextBlock, otherwise it will calculate the Union of the BoundingBoxes of all its Children. If called on the Document, it will return the cropbox of each page
      Specified by:
      getBBox in interface SemanticNode
      Returns:
      Rectangle2D fully encapsulating this Node for each page.
    • streamEntitiesWhereRowContainsStringsIgnoreCase

      public Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> streamEntitiesWhereRowContainsStringsIgnoreCase(List<String> strings)
      Streams all entities in this table, that appear in a row, which contains any of the provided strings.
      Parameters:
      strings - Strings to check whether a row contains them
      Returns:
      Stream of all entities in this table, that appear in a row, which contains any of the provided strings
    • rowContainsStringsIgnoreCase

      public boolean rowContainsStringsIgnoreCase(Integer row, List<String> strings)
      Checks whether the specified row contains all the provided strings.
      Parameters:
      row - the row to check as an Integer, must be smaller than numberOfRows
      strings - a list of strings to check for
      Returns:
      true, if all strings appear in the provided row
    • streamEntitiesWhereRowHasHeaderAndValue

      public Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> streamEntitiesWhereRowHasHeaderAndValue(String header, String value)
      Streams all entities which appear in a row where at least one cell has the provided header and the provided value.
      Parameters:
      header - the header value to search for
      value - the string which the table cell should contain
      Returns:
      a stream of all entities, which appear in a row where at least one cell has the provided header and the provided value.
    • streamEntitiesWhereRowHasHeaderAndAnyValue

      public Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> streamEntitiesWhereRowHasHeaderAndAnyValue(String header, List<String> values)
      Streams all entities which appear in a row where at least one cell has the provided header and any provided value.
      Parameters:
      header - the header value to search for
      values - the strings which the table cell should contain
      Returns:
      a stream of all entities, which appear in a row where at least one cell has the provided header and any provided value.
    • streamEntitiesWhereRowContainsEntitiesOfType

      public Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> streamEntitiesWhereRowContainsEntitiesOfType(List<String> types)
      Streams all entities in this table, that appear in a row, which contains at least one valid entity with any of the provided types. Ignores Entity with ignored == true or removed == true.
      Parameters:
      types - type strings to check whether a row contains an entity like them
      Returns:
      Stream of all entities in this table, that appear in a row, which contains at least one valid entity with any of the provided types.
    • streamEntitiesWhereRowContainsEntitiesOfEachType

      public Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> streamEntitiesWhereRowContainsEntitiesOfEachType(List<String> types)
      Streams all entities in this table, that appear in a row, which contains at least one entity of each of the provided types. Ignores Entity with ignored == true or removed == true.
      Parameters:
      types - type strings to check whether a row contains an entity like them
      Returns:
      Stream of all entities in this table, that appear in a row, which contains at least one entity of each of the provided types.
    • streamEntitiesWhereRowContainsNoEntitiesOfType

      public Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> streamEntitiesWhereRowContainsNoEntitiesOfType(List<String> types)
      Streams all entities in this table, that appear in a row, which contains no entity of any of the provided types. Ignores Entity with ignored == true or removed == true.
      Parameters:
      types - type strings to check whether a row contains an entity like them
      Returns:
      Stream of all entities in this table, that appear in a row, which contains at least one entity with any of the provided types.
    • streamTextEntitiesInRow

      public Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> streamTextEntitiesInRow(int rowNumber)
      Streams all valid Entities in the given row.
      Parameters:
      rowNumber - the row number to look for
      Returns:
      stream of TextEntities occurring in row
    • streamTextEntitiesInCol

      public Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> streamTextEntitiesInCol(int colNumber)
      Streams all valid Entities in the given col.
      Parameters:
      colNumber - the column number to look for
      Returns:
      stream of TextEntities occurring in row
    • getCell

      public TableCell getCell(int row, int col)
      Returns a TableCell at the provided row and column location.
      Parameters:
      row - int representing the row, must be smaller than numberOfRows
      col - int representing the col, must be smaller than numberOfCols
      Returns:
      TableCell at the provided location in the table
    • streamTableCells

      public Stream<TableCell> streamTableCells()
      Streams all TableCells in this Table row-wise.
      Returns:
      Stream of all TableCells
    • streamTableCellsWhichContainType

      public Stream<TableCell> streamTableCellsWhichContainType(String type)
      Streams all TableCells that contain at least one entity of a given type in this Table row-wise.
      Parameters:
      type - The type of the entity
      Returns:
      Stream of filtered TableCells
    • streamTableCellsWithHeader

      public Stream<TableCell> streamTableCellsWithHeader(String header)
      Streams all TableCells in this Table which have the provided header row-wise.
      Returns:
      Stream of all TableCells which have the provided header
    • streamCol

      public Stream<TableCell> streamCol(int col)
      Streams all TableCells belonging to the provided column from top down.
      Parameters:
      col - int representing the column
      Returns:
      Stream of all TableCell in the provided column
    • streamRow

      public Stream<TableCell> streamRow(int row)
      Streams all TableCells belonging to the provided row from left to right.
      Parameters:
      row - int representing the row
      Returns:
      Stream of all TableCell in the provided row
    • streamHeaders

      public Stream<TableCell> streamHeaders()
      Streams all TableCells row-wise and filters them with header == true.
      Returns:
      Stream of all TableCells with header == true
    • streamHeadersForCell

      public Stream<TableCell> streamHeadersForCell(int row, int col)
      Streams all TableCells of the provided row and column and filters them with header == true.
      Parameters:
      row - int representing the row
      col - int representing the column
      Returns:
      Stream of all TableCells with header == true in the provided row or col
    • hasHeader

      public boolean hasHeader(String header)
      Streams all Headers and checks if any equal the provided string.
      Parameters:
      header - string to check the headers for
      Returns:
      true, if at least one header equals the provided string
    • hasHeaderIgnoreCase

      public boolean hasHeaderIgnoreCase(String header)
      Streams all Headers and checks if any equal the provided string.
      Parameters:
      header - string to check the headers for
      Returns:
      true, if at least one header equals the provided string
    • hasRowWithHeaderAndValue

      public boolean hasRowWithHeaderAndValue(String header, String value)
      Checks if this table has a column with the provided header and any of the table cells in that column contain the provided value.
      Parameters:
      header - string to find header cells
      value - string to check cells with provided header
      Returns:
      true, if this table has a column with the provided header and any of the table cells in that column contain the provided value
    • hasRowWithHeaderAndAnyValue

      public boolean hasRowWithHeaderAndAnyValue(String header, List<String> values)
      Checks if this table has a column with the provided header and any of the table cells in that column contains any of the provided values.
      Parameters:
      header - string to find header cells
      values - List of strings to check cells with provided header
      Returns:
      true, if this table has a column with the provided header and any of the table cells in that column contains any of the provided values.
    • getEntitiesOfTypeInSameRow

      public List<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> getEntitiesOfTypeInSameRow(String type, com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity textEntity)
      Finds all entities of the provided type, which appear in the same row that the provided entity appears in. Ignores Entity with ignored == true or removed == true.
      Parameters:
      type - the type of entities to search for
      textEntity - the entity, which appears in the row to search
      Returns:
      List of all entities of the provided type, which appear in the same row that the provided entity appears in.
    • getType

      public NodeType getType()
      Description copied from interface: SemanticNode
      Returns the type of this node, such as Section, Paragraph, etc.
      Specified by:
      getType in interface SemanticNode
      Returns:
      NodeType of this node
    • getTextBlock

      public com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock getTextBlock()
      Description copied from interface: SemanticNode
      Searches all Nodes located underneath this Node in the DocumentTree and concatenates their AtomicTextBlocks into a single TextBlock. So, for a Section all TextBlocks of Subsections, Paragraphs, and Tables are concatenated into a single TextBlock If the Node is a Leaf, the LeafTextBlock will be returned instead.
      Specified by:
      getTextBlock in interface SemanticNode
      Returns:
      TextBlock containing all AtomicTextBlocks that are located under this Node.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static Table.TableBuilder builder()
    • getEngines

      public Set<com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine> getEngines()
      Specified by:
      getEngines in interface SemanticNode
    • getTreeId

      public List<Integer> getTreeId()
      Description copied from interface: SemanticNode
      The id is a List of Integers uniquely identifying this node in the DocumentTree.
      Specified by:
      getTreeId in interface SemanticNode
      Returns:
      the DocumentTree ID
    • getDocumentTree

      public com.iqser.red.service.redaction.v1.server.model.document.DocumentTree getDocumentTree()
      Description copied from interface: SemanticNode
      Returns the DocumentTree Object.
      Specified by:
      getDocumentTree in interface SemanticNode
      Returns:
      the DocumentTree of the Document this node belongs to
    • getNumberOfRows

      public int getNumberOfRows()
    • getNumberOfCols

      public int getNumberOfCols()
    • getEntities

      public Set<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> getEntities()
      Description copied from interface: SemanticNode
      Any Node maintains its own Set of Entities. This Set contains all Entities whose TextRange intersects the TextRange of this node.
      Specified by:
      getEntities in interface SemanticNode
      Returns:
      Set of all Entities associated with this Node
    • getBBoxCache

      public Map<Page,Rectangle2D> getBBoxCache()
    • setEngines

      public void setEngines(Set<com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine> engines)
    • setTreeId

      public void setTreeId(List<Integer> treeId)
      Description copied from interface: SemanticNode
      This should only be used during graph construction.
      Specified by:
      setTreeId in interface SemanticNode
      Parameters:
      treeId - List of Integers
    • setDocumentTree

      public void setDocumentTree(com.iqser.red.service.redaction.v1.server.model.document.DocumentTree documentTree)
    • setNumberOfRows

      public void setNumberOfRows(int numberOfRows)
    • setNumberOfCols

      public void setNumberOfCols(int numberOfCols)
    • setTextBlock

      public void setTextBlock(com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock)
    • setEntities

      public void setEntities(Set<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> entities)
    • setBBoxCache

      public void setBBoxCache(Map<Page,Rectangle2D> bBoxCache)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object