Class Table
java.lang.Object
com.iqser.red.service.redaction.v1.server.model.document.nodes.Table
- All Implemented Interfaces:
SemanticNode
Represents a table within a document.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionTable
(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 Summary
Modifier and TypeMethodDescriptionstatic Table.TableBuilder
builder()
boolean
getBBox()
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.getCell
(int row, int col) Returns a TableCell at the provided row and column location.com.iqser.red.service.redaction.v1.server.model.document.DocumentTree
Returns the DocumentTree Object.Set<com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine>
Set<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity>
Any Node maintains its own Set of Entities.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.int
int
com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock
Searches all Nodes located underneath this Node in the DocumentTree and concatenates their AtomicTextBlocks into a single TextBlock.The id is a List of Integers uniquely identifying this node in the DocumentTree.getType()
Returns the type of this node, such as Section, Paragraph, etc.int
hashCode()
boolean
Streams all Headers and checks if any equal the provided string.boolean
hasHeaderIgnoreCase
(String header) Streams all Headers and checks if any equal the provided string.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.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.boolean
rowContainsStringsIgnoreCase
(Integer row, List<String> strings) Checks whether the specified row contains all the provided strings.void
setBBoxCache
(Map<Page, Rectangle2D> bBoxCache) void
setDocumentTree
(com.iqser.red.service.redaction.v1.server.model.document.DocumentTree documentTree) void
setEngines
(Set<com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine> engines) void
setEntities
(Set<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity> entities) void
setNumberOfCols
(int numberOfCols) void
setNumberOfRows
(int numberOfRows) void
setTextBlock
(com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock textBlock) void
This should only be used during graph construction.streamCol
(int col) Streams all TableCells belonging to the provided column from top down.Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity>
Streams all entities in this table, that appear in a row, which contains at least one entity of each of the provided types.Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity>
Streams all entities in this table, that appear in a row, which contains at least one valid entity with any of the provided types.Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity>
Streams all entities in this table, that appear in a row, which contains no entity of any of the provided types.Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity>
Streams all entities in this table, that appear in a row, which contains any of the provided strings.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.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.Streams all TableCells row-wise and filters them with header == true.streamHeadersForCell
(int row, int col) Streams all TableCells of the provided row and column and filters them with header == true.streamRow
(int row) Streams all TableCells belonging to the provided row from left to right.Streams all TableCells in this Table row-wise.Streams all TableCells that contain at least one entity of a given type in this Table row-wise.streamTableCellsWithHeader
(String header) Streams all TableCells in this Table which have the provided header row-wise.Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity>
streamTextEntitiesInCol
(int colNumber) Streams all valid Entities in the given col.Stream<com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity>
streamTextEntitiesInRow
(int rowNumber) Streams all valid Entities in the given row.toString()
Methods inherited from interface com.iqser.red.service.redaction.v1.server.model.document.nodes.SemanticNode
accept, addEngine, addThisToEntityIfIntersects, containsAllStrings, containsAllStringsIgnoreCase, containsAllWords, containsAllWordsIgnoreCase, containsAnyString, containsAnyString, containsAnyStringIgnoreCase, containsAnyWord, containsAnyWordIgnoreCase, containsRectangle, containsString, containsStringIgnoreCase, containsWord, containsWordIgnoreCase, getEntitiesOfType, getEntitiesOfType, getEntitiesOfType, getFirstPage, getHeadline, getHighestParent, getLeafTextBlock, getNextSibling, getNumberOnPage, getPages, getPages, getParent, getPositionsPerPage, getPreviousSibling, getSectionIdentifier, getTextBlocksByPageNumbers, getTextRange, hasEntitiesOfAllTypes, hasEntitiesOfAnyType, hasEntitiesOfType, hasParent, hasText, intersectsRectangle, isLeaf, length, matchesRegex, matchesRegexIgnoreCase, onlyOnPage, onPage, setLeafTextBlock, streamAllSubNodes, streamAllSubNodesOfType, streamChildren, streamChildrenOfType, streamValidEntities
-
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
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 interfaceSemanticNode
- 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
Checks whether the specified row contains all the provided strings.- Parameters:
row
- the row to check as an Integer, must be smaller than numberOfRowsstrings
- 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 forvalue
- 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 forvalues
- 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
Returns a TableCell at the provided row and column location.- Parameters:
row
- int representing the row, must be smaller than numberOfRowscol
- int representing the col, must be smaller than numberOfCols- Returns:
- TableCell at the provided location in the table
-
streamTableCells
Streams all TableCells in this Table row-wise.- Returns:
- Stream of all TableCells
-
streamTableCellsWhichContainType
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
Streams all TableCells in this Table which have the provided header row-wise.- Returns:
- Stream of all TableCells which have the provided header
-
streamCol
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
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
Streams all TableCells row-wise and filters them with header == true.- Returns:
- Stream of all TableCells with header == true
-
streamHeadersForCell
Streams all TableCells of the provided row and column and filters them with header == true.- Parameters:
row
- int representing the rowcol
- int representing the column- Returns:
- Stream of all TableCells with header == true in the provided row or col
-
hasHeader
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
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
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 cellsvalue
- 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
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 cellsvalues
- 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 fortextEntity
- 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
Description copied from interface:SemanticNode
Returns the type of this node, such as Section, Paragraph, etc.- Specified by:
getType
in interfaceSemanticNode
- 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 interfaceSemanticNode
- Returns:
- TextBlock containing all AtomicTextBlocks that are located under this Node.
-
toString
-
builder
-
getEngines
public Set<com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine> getEngines()- Specified by:
getEngines
in interfaceSemanticNode
-
getTreeId
Description copied from interface:SemanticNode
The id is a List of Integers uniquely identifying this node in the DocumentTree.- Specified by:
getTreeId
in interfaceSemanticNode
- 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 interfaceSemanticNode
- 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 interfaceSemanticNode
- Returns:
- Set of all Entities associated with this Node
-
getBBoxCache
-
setEngines
public void setEngines(Set<com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine> engines) -
setTreeId
Description copied from interface:SemanticNode
This should only be used during graph construction.- Specified by:
setTreeId
in interfaceSemanticNode
- 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
-
equals
-
hashCode
public int hashCode()
-