From a6eb3dc2ff3a5220a1df151d60f23082620c01df Mon Sep 17 00:00:00 2001 From: Maverick Studer Date: Wed, 8 Jan 2025 13:19:45 +0100 Subject: [PATCH] RED-10687: Filter out overlapping recommendations if they are of the same type --- .../src/main/resources/drools/all_rules_documine.drl | 11 +++++++++++ .../src/test/resources/drools/acceptance_rules.drl | 11 +++++++++++ .../resources/drools/all_redact_manager_rules.drl | 11 +++++++++++ .../src/test/resources/drools/documine_flora.drl | 11 +++++++++++ .../src/test/resources/drools/efsa_sanitisation.drl | 11 +++++++++++ .../test/resources/drools/manual_redaction_rules.drl | 11 +++++++++++ .../src/test/resources/drools/rules.drl | 11 +++++++++++ .../src/test/resources/drools/rules_v2.drl | 11 +++++++++++ .../src/test/resources/drools/table_demo.drl | 11 +++++++++++ .../src/test/resources/drools/test_rules.drl | 11 +++++++++++ .../src/test/resources/files/syngenta | 2 +- .../dictionaries/EFSA_sanitisation_GFL_v1/rules.drl | 11 +++++++++++ .../src/main/resources/all_redact_manager_rules.drl | 11 +++++++++++ .../src/main/resources/all_rules_documine.drl | 11 +++++++++++ 14 files changed, 144 insertions(+), 1 deletion(-) diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/resources/drools/all_rules_documine.drl b/redaction-service-v1/redaction-service-server-v1/src/main/resources/drools/all_rules_documine.drl index 8c82300d..216d0e68 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/resources/drools/all_rules_documine.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/main/resources/drools/all_rules_documine.drl @@ -1548,6 +1548,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.7 rule "X.7.0: Remove all images" salience 512 diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl index f6ed23d5..6560b179 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl @@ -1350,6 +1350,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.6 rule "X.6.0: Remove Entity of lower rank, when contained by entity of type ENTITY or HINT" salience 32 diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl index 1085dc13..0b9ba0c0 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl @@ -2117,6 +2117,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.6 rule "X.6.0: Remove Entity of lower rank, when contained by entity of type ENTITY or HINT" salience 32 diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/documine_flora.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/documine_flora.drl index 8b3442c1..925d3307 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/documine_flora.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/documine_flora.drl @@ -1485,6 +1485,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.7 rule "X.7.0: Remove all images" salience 512 diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/efsa_sanitisation.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/efsa_sanitisation.drl index 61fab113..da2aacf0 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/efsa_sanitisation.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/efsa_sanitisation.drl @@ -1077,6 +1077,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.6 rule "X.6.0: Remove Entity of lower rank, when contained by entity of type ENTITY or HINT" salience 32 diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/manual_redaction_rules.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/manual_redaction_rules.drl index 47594a31..e243423b 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/manual_redaction_rules.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/manual_redaction_rules.drl @@ -397,6 +397,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.6 rule "X.6.0: Remove Entity of lower rank, when contained by entity of type ENTITY or HINT" salience 32 diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/rules.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/rules.drl index 929fb9d1..b8a236ca 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/rules.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/rules.drl @@ -1372,6 +1372,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.6 rule "X.6.0: Remove Entity of lower rank, when contained by entity of type ENTITY or HINT" salience 32 diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/rules_v2.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/rules_v2.drl index 17e1c255..53d58229 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/rules_v2.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/rules_v2.drl @@ -455,6 +455,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.6 rule "X.6.0: Remove Entity of lower rank, when contained by entity of type ENTITY or HINT" salience 32 diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/table_demo.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/table_demo.drl index 0166e897..faed5ae2 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/table_demo.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/table_demo.drl @@ -547,6 +547,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.6 rule "X.6.0: Remove Entity of lower rank, when contained by entity of type ENTITY or HINT" salience 32 diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/test_rules.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/test_rules.drl index 9c5c810d..c7450096 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/test_rules.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/test_rules.drl @@ -468,6 +468,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.6 rule "X.6.0: Remove Entity of lower rank, when contained by entity of type ENTITY or HINT" salience 32 diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/files/syngenta b/redaction-service-v1/redaction-service-server-v1/src/test/resources/files/syngenta index 5705cc07..57e6e0dd 160000 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/files/syngenta +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/files/syngenta @@ -1 +1 @@ -Subproject commit 5705cc0782605fdca5dfff134b436f7143c9e421 +Subproject commit 57e6e0dd3c08a3a65ec59b5dfb70f0f77ebcc7c7 diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/performance/dictionaries/EFSA_sanitisation_GFL_v1/rules.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/performance/dictionaries/EFSA_sanitisation_GFL_v1/rules.drl index a8d7470b..e3bfe0d6 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/performance/dictionaries/EFSA_sanitisation_GFL_v1/rules.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/performance/dictionaries/EFSA_sanitisation_GFL_v1/rules.drl @@ -960,6 +960,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.6 rule "X.6.0: Remove Entity of lower rank, when contained by entity of type ENTITY or HINT" salience 32 diff --git a/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl b/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl index b6139172..8b668fc0 100644 --- a/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl +++ b/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl @@ -2147,6 +2147,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.6 rule "X.6.0: Remove Entity of lower rank, when contained by entity of type ENTITY or HINT" salience 32 diff --git a/redaction-service-v1/rules-management/src/main/resources/all_rules_documine.drl b/redaction-service-v1/rules-management/src/main/resources/all_rules_documine.drl index 3eac9dd4..ff37611f 100644 --- a/redaction-service-v1/rules-management/src/main/resources/all_rules_documine.drl +++ b/redaction-service-v1/rules-management/src/main/resources/all_rules_documine.drl @@ -1554,6 +1554,17 @@ rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATI end +rule "X.5.2: Remove Entity of type RECOMMENDATION when contained by ENTITY of same type" + salience 256 + when + $entity: TextEntity($type: type(), (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !removed()) + $recommendation: TextEntity(containedBy($entity), type() == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges()) + then + $recommendation.remove("X.5.2", "remove Entity of type RECOMMENDATION when contained by ENTITY of same type"); + retract($recommendation); + end + + // Rule unit: X.7 rule "X.7.0: Remove all images" salience 512