Merge branch 'RED-7898' into 'master'

RED-7898 - Publish rule is not applied line-wise

Closes RED-7898

See merge request redactmanager/redaction-service!190
This commit is contained in:
Andrei Isvoran 2023-11-10 14:29:58 +01:00
commit 3a685e5671
6 changed files with 22 additions and 15 deletions

View File

@ -172,6 +172,18 @@ public class Table implements SemanticNode {
return streamChildrenOfType(NodeType.TABLE_CELL).map(node -> (TableCell) node);
}
/**
* Streams all TableCells that contain at least one entity of a given type in this Table row-wise.
*
* @param type The type of the entity
* @return Stream of filtered TableCells
*/
public Stream<TableCell> streamTableCellsWhichContainType(String type) {
return streamTableCells()
.filter(tableCell -> tableCell.getEntities().stream().filter(TextEntity::active).anyMatch(entity -> entity.getType().equals(type)));
}
/**
* Streams all TableCells in this Table which have the provided header row-wise.

View File

@ -147,9 +147,8 @@ rule "CBI.7.0: Do not redact Names and Addresses if published information found
rule "CBI.7.1: Do not redact Names and Addresses if published information found in same table row"
when
$table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("CBI_author"))
$tableCell: TableCell() from $table.streamTableCells().toList()
$sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList()
TextEntity(type == "published_information", active()) from $tableCell.getEntities()
$cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList()
$tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList()
$author: TextEntity(type == "CBI_author", active()) from $tableCell.getEntities()
then
$author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author));

View File

@ -330,9 +330,8 @@ rule "CBI.7.0: Do not redact Names and Addresses if published information found
rule "CBI.7.1: Do not redact Names and Addresses if published information found in same table row"
when
$table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("CBI_author"))
$tableCell: TableCell() from $table.streamTableCells().toList()
$sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList()
TextEntity(type == "published_information", active()) from $tableCell.getEntities()
$cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList()
$tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList()
$author: TextEntity(type == "CBI_author", active()) from $tableCell.getEntities()
then
$author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author));

View File

@ -143,9 +143,8 @@ rule "CBI.7.0: Do not redact Names and Addresses if published information found
rule "CBI.7.1: Do not redact Names and Addresses if published information found in same table row"
when
$table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("CBI_author"))
$tableCell: TableCell() from $table.streamTableCells().toList()
$sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList()
TextEntity(type == "published_information", active()) from $tableCell.getEntities()
$cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList()
$tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList()
$author: TextEntity(type == "CBI_author", active()) from $tableCell.getEntities()
then
$author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author));

View File

@ -330,9 +330,8 @@ rule "CBI.7.0: Do not redact Names and Addresses if published information found
rule "CBI.7.1: Do not redact Names and Addresses if published information found in same table row"
when
$table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("CBI_author"))
$tableCell: TableCell() from $table.streamTableCells().toList()
$sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList()
TextEntity(type == "published_information", active()) from $tableCell.getEntities()
$cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList()
$tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList()
$author: TextEntity(type == "CBI_author", active()) from $tableCell.getEntities()
then
$author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author));

View File

@ -330,9 +330,8 @@ rule "CBI.7.0: Do not redact Names and Addresses if published information found
rule "CBI.7.1: Do not redact Names and Addresses if published information found in same table row"
when
$table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("CBI_author"))
$tableCell: TableCell() from $table.streamTableCells().toList()
$sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList()
TextEntity(type == "published_information", active()) from $tableCell.getEntities()
$cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList()
$tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList()
$author: TextEntity(type == "CBI_author", active()) from $tableCell.getEntities()
then
$author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author));