diff --git a/redaction-service-v1/redaction-service-api-v1/pom.xml b/redaction-service-v1/redaction-service-api-v1/pom.xml
index 5009bbf3..c739a0cc 100644
--- a/redaction-service-v1/redaction-service-api-v1/pom.xml
+++ b/redaction-service-v1/redaction-service-api-v1/pom.xml
@@ -40,4 +40,22 @@
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+
+
+
+
+
+
diff --git a/redaction-service-v1/redaction-service-server-v1/pom.xml b/redaction-service-v1/redaction-service-server-v1/pom.xml
index 32943299..2f090926 100644
--- a/redaction-service-v1/redaction-service-server-v1/pom.xml
+++ b/redaction-service-v1/redaction-service-server-v1/pom.xml
@@ -132,4 +132,75 @@
test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+
+
+
+
+
+
+
+ pl.project13.maven
+ git-commit-id-plugin
+
+
+
+ revision
+
+
+ true
+
+ true
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+ original-jar
+
+ jar
+
+
+ original
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+ true
+
+
+
+
+
+
diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/layoutparsing/document/graph/nodes/Table.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/layoutparsing/document/graph/nodes/Table.java
index b3359c49..3e00e7a3 100644
--- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/layoutparsing/document/graph/nodes/Table.java
+++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/layoutparsing/document/graph/nodes/Table.java
@@ -40,6 +40,12 @@ public class Table implements SemanticNode {
Set entities = new HashSet<>();
+ /**
+ * Streams all entities in this table, that appear in a row, which contains any of the provided strings.
+ *
+ * @param strings Strings to check whether a row contains them
+ * @return Stream of all entities in this table, that appear in a row, which contains any of the provided strings
+ */
public Stream streamEntitiesWhereRowContainsStringsIgnoreCase(List strings) {
return IntStream.range(0, numberOfRows)
@@ -51,6 +57,13 @@ public class Table implements SemanticNode {
}
+ /**
+ * Checks whether the specified row contains all the provided strings.
+ *
+ * @param row the row to check as an Integer, must be smaller than numberOfRows
+ * @param strings a list of strings to check for
+ * @return true, if all strings appear in the provided row
+ */
public boolean rowContainsStringsIgnoreCase(Integer row, List strings) {
String rowText = streamRow(row).map(TableCell::buildTextBlock).collect(new TextBlockCollector()).getSearchText().toLowerCase();
@@ -58,6 +71,13 @@ public class Table implements SemanticNode {
}
+ /**
+ * Streams all entities which appear in a row where at least one cell has the provided header and the provided value.
+ *
+ * @param header the header value to search for
+ * @param value the string which the table cell should contain
+ * @return a stream of all entities, which appear in a row where at least one cell has the provided header and the provided value.
+ */
public Stream streamEntitiesWhereRowHasHeaderAndValue(String header, String value) {
List vertebrateStudyCols = streamHeaders().filter(headerNode -> headerNode.containsString(header)).map(TableCell::getCol).toList();
@@ -66,6 +86,13 @@ public class Table implements SemanticNode {
}
+ /**
+ * Streams all entities which appear in a row where at least one cell has the provided header and any provided value.
+ *
+ * @param header the header value to search for
+ * @param values the strings which the table cell should contain
+ * @return a stream of all entities, which appear in a row where at least one cell has the provided header and any provided value.
+ */
public Stream streamEntitiesWhereRowHasHeaderAndAnyValue(String header, List values) {
List vertebrateStudyCols = streamHeaders().filter(headerNode -> headerNode.containsString(header)).map(TableCell::getCol).toList();
@@ -76,6 +103,12 @@ public class Table implements SemanticNode {
}
+ /**
+ * Streams all entities in this table, that appear in a row, which contains at least one entity with any of the provided types.
+ *
+ * @param types type strings to check whether a row contains an entity like them
+ * @return Stream of all entities in this table, that appear in a row, which contains at least one entity with any of the provided types.
+ */
public Stream streamEntitiesWhereRowContainsEntitiesOfType(List types) {
List rowsWithEntityOfType = getEntities().stream()
@@ -90,6 +123,13 @@ public class Table implements SemanticNode {
}
+ /**
+ * Returns a TableCell at the provided row and column location.
+ *
+ * @param row int representing the row, must be smaller than numberOfRows
+ * @param col int representing the col, must be smaller than numberOfCols
+ * @return TableCell at the provided location in the table
+ */
public TableCell getCell(int row, int col) {
if (numberOfRows - row < 0 || numberOfCols - col < 0) {
@@ -100,12 +140,22 @@ public class Table implements SemanticNode {
}
+ /**
+ * Streams all TableCells in this Table row-wise.
+ *
+ * @return Stream of all TableCells
+ */
public Stream streamTableCells() {
return streamChildren().map(node -> (TableCell) node);
}
+ /**
+ * Streams all TableCells in this Table which have the provided header row-wise.
+ *
+ * @return Stream of all TableCells which have the provided header
+ */
public Stream streamTableCellsWithHeader(String header) {
return streamHeaders().filter(tableCellNode -> tableCellNode.buildTextBlock().getSearchText().contains(header))
@@ -115,48 +165,99 @@ public class Table implements SemanticNode {
}
+ /**
+ * Streams all TableCells belonging to the provided column from top down.
+ *
+ * @param col int representing the column
+ * @return Stream of all TableCell in the provided column
+ */
public Stream streamCol(int col) {
return IntStream.range(0, numberOfRows).boxed().map(row -> getCell(row, col));
}
+ /**
+ * Streams all TableCells belonging to the provided row from left to right.
+ *
+ * @param row int representing the row
+ * @return Stream of all TableCell in the provided row
+ */
public Stream streamRow(int row) {
return IntStream.range(0, numberOfCols).boxed().map(col -> getCell(row, col));
}
+ /**
+ * Streams all TableCells row-wise and filters them with header == true.
+ *
+ * @return Stream of all TableCells with header == true
+ */
public Stream streamHeaders() {
return streamTableCells().filter(TableCell::isHeader);
}
+ /**
+ * Streams all TableCells of the provided row and column and filters them with header == true.
+ *
+ * @param row int representing the row
+ * @param col int representing the column
+ * @return Stream of all TableCells with header == true in the provided row or col
+ */
public Stream streamHeadersForCell(int row, int col) {
return Stream.concat(streamRow(row), streamCol(col)).filter(TableCell::isHeader);
}
+ /**
+ * Streams all Headers and checks if any equal the provided string.
+ *
+ * @param header string to check the headers for
+ * @return true, if at least one header equals the provided string
+ */
public boolean hasHeader(String header) {
return streamHeaders().anyMatch(tableCellNode -> tableCellNode.buildTextBlock().getSearchText().strip().equals(header));
}
+ /**
+ * Checks if this table has a column with the provided header and any of the table cells in that column contain the provided value.
+ *
+ * @param header string to find header cells
+ * @param value string to check cells with provided header
+ * @return true, if this table has a column with the provided header and any of the table cells in that column contain the provided value
+ */
public boolean hasRowWithHeaderAndValue(String header, String value) {
return streamTableCellsWithHeader(header).anyMatch(tableCellNode -> tableCellNode.containsString(value));
}
+ /**
+ * 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.
+ *
+ * @param header string to find header cells
+ * @param values List of strings to check cells with provided header
+ * @return 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.
+ */
public boolean hasRowWithHeaderAndAnyValue(String header, List values) {
return streamTableCellsWithHeader(header).anyMatch(tableCellNode -> tableCellNode.containsAnyString(values));
}
+ /**
+ * Finds all entities of the provided type, which appear in the same row that the provided entity appears in.
+ *
+ * @param type the type of entities to search for
+ * @param redactionEntity the entity, which appears in the row to search
+ * @return List of all entities of the provided type, which appear in the same row that the provided entity appears in.
+ */
public List getEntitiesOfTypeInSameRow(String type, RedactionEntity redactionEntity) {
return redactionEntity.getIntersectingNodes()
diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/layoutparsing/document/graph/nodes/TableCell.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/layoutparsing/document/graph/nodes/TableCell.java
index 312a7d51..61399350 100644
--- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/layoutparsing/document/graph/nodes/TableCell.java
+++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/layoutparsing/document/graph/nodes/TableCell.java
@@ -6,7 +6,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.stream.Stream;
import com.iqser.red.service.redaction.v1.server.layoutparsing.document.graph.DocumentTree;
import com.iqser.red.service.redaction.v1.server.layoutparsing.document.graph.entity.RedactionEntity;
@@ -76,17 +75,4 @@ public class TableCell implements SemanticNode {
return treeId + ": " + NodeType.TABLE_CELL + ": " + buildTextBlock().buildSummary();
}
-
- public boolean hasHeader(String headerString) {
-
- return getHeaders().anyMatch(header -> header.buildTextBlock().getSearchText().strip().equals(headerString));
- }
-
-
- private Stream getHeaders() {
-
- Table table = (Table) getParent();
- return table.streamHeadersForCell(row, col);
- }
-
}