From b8e4f64520ff7813f271b11e8ce6b876866c2537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominique=20Eifl=C3=A4nder?= Date: Thu, 25 Jan 2024 14:41:39 +0100 Subject: [PATCH] RED-7901: Changed rules to remove all recommendations that intersect with entities --- .../resources/drools/acceptance_rules.drl | 22 ++++++++++++----- .../drools/all_redact_manager_rules.drl | 22 ++++++++++++----- .../test/resources/drools/documine_flora.drl | 22 ++++++++++++----- .../drools/manual_redaction_rules.drl | 14 +++++++++++ .../src/test/resources/drools/rules.drl | 22 ++++++++++++----- .../src/test/resources/drools/rules_v2.drl | 22 ++++++++++++----- .../src/test/resources/drools/table_demo.drl | 22 ++++++++++++----- .../src/test/resources/drools/test_rules.drl | 22 ++++++++++++----- .../resources/all_redact_manager_rules.drl | 24 ++++++++++++++----- .../src/main/resources/all_rules_documine.drl | 24 ++++++++++++++----- .../resources/default_rule_identifiers.txt | 1 + .../resources/default_rule_identifiers_dm.txt | 1 + 12 files changed, 164 insertions(+), 54 deletions(-) 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 4a92feac..77de7a61 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 @@ -934,26 +934,36 @@ rule "X.3.0: Remove Entity of type RECOMMENDATION when contained by FALSE_RECOMM // Rule unit: X.4 -rule "X.4.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY with same type" +rule "X.4.0: Remove Entity of type RECOMMENDATION when text range equals ENTITY with same type" salience 256 when $entity: TextEntity($type: type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(intersects($entity), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(getTextRange().equals($entity.getTextRange()), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then $entity.addEngines($recommendation.getEngines()); - $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY with same type"); + $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when text range equals ENTITY with same type"); retract($recommendation); end // Rule unit: X.5 -rule "X.5.0: Remove Entity of type RECOMMENDATION when contained by ENTITY" +rule "X.5.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY" salience 256 when $entity: TextEntity((entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(containedBy($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(intersects($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then - $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when contained by ENTITY"); + $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY"); + retract($recommendation); + end + +rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATION" + salience 256 + when + $entity: TextEntity($type: type, entityType == EntityType.RECOMMENDATION, active()) + $recommendation: TextEntity(containedBy($entity), type != $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + then + $recommendation.remove("X.5.1", "remove Entity of type RECOMMENDATION when contained by RECOMMENDATION"); retract($recommendation); end 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 e0b255c9..9bac0739 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 @@ -1504,26 +1504,36 @@ rule "X.3.0: Remove Entity of type RECOMMENDATION when contained by FALSE_RECOMM // Rule unit: X.4 -rule "X.4.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY with same type" +rule "X.4.0: Remove Entity of type RECOMMENDATION when text range equals ENTITY with same type" salience 256 when $entity: TextEntity($type: type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(intersects($entity), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(getTextRange().equals($entity.getTextRange()), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then $entity.addEngines($recommendation.getEngines()); - $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY with same type"); + $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when text range equals ENTITY with same type"); retract($recommendation); end // Rule unit: X.5 -rule "X.5.0: Remove Entity of type RECOMMENDATION when contained by ENTITY" +rule "X.5.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY" salience 256 when $entity: TextEntity((entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(containedBy($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(intersects($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then - $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when contained by ENTITY"); + $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY"); + retract($recommendation); + end + +rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATION" + salience 256 + when + $entity: TextEntity($type: type, entityType == EntityType.RECOMMENDATION, active()) + $recommendation: TextEntity(containedBy($entity), type != $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + then + $recommendation.remove("X.5.1", "remove Entity of type RECOMMENDATION when contained by RECOMMENDATION"); retract($recommendation); end 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 eae06bf8..07914971 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 @@ -1346,26 +1346,36 @@ rule "X.3.0: Remove Entity of type RECOMMENDATION when contained by FALSE_RECOMM // Rule unit: X.4 -rule "X.4.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY with same type" +rule "X.4.0: Remove Entity of type RECOMMENDATION when text range equals ENTITY with same type" salience 256 when $entity: TextEntity($type: type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(intersects($entity), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(getTextRange().equals($entity.getTextRange()), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then $entity.addEngines($recommendation.getEngines()); - $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY with same type"); + $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when text range equals ENTITY with same type"); retract($recommendation); end // Rule unit: X.5 -rule "X.5.0: Remove Entity of type RECOMMENDATION when contained by ENTITY" +rule "X.5.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY" salience 256 when $entity: TextEntity((entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(containedBy($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(intersects($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then - $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when contained by ENTITY"); + $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY"); + retract($recommendation); + end + +rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATION" + salience 256 + when + $entity: TextEntity($type: type, entityType == EntityType.RECOMMENDATION, active()) + $recommendation: TextEntity(containedBy($entity), type != $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + then + $recommendation.remove("X.5.1", "remove Entity of type RECOMMENDATION when contained by RECOMMENDATION"); retract($recommendation); end 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 a97e0e71..e1b8dec1 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 @@ -220,6 +220,20 @@ rule "MAN.4.1: Apply legal basis change" end +//------------------------------------ Entity merging rules ------------------------------------ + +// Rule unit: X.5 +rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATION" + salience 256 + when + $entity: TextEntity($type: type, entityType == EntityType.RECOMMENDATION, active()) + $recommendation: TextEntity(containedBy($entity), type != $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + then + $recommendation.remove("X.5.1", "remove Entity of type RECOMMENDATION when contained by RECOMMENDATION"); + retract($recommendation); + end + + //------------------------------------ Local dictionary search rules ------------------------------------ // Rule unit: LDS.0 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 136d7b20..2730084b 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 @@ -1094,26 +1094,36 @@ rule "X.3.0: Remove Entity of type RECOMMENDATION when contained by FALSE_RECOMM // Rule unit: X.4 -rule "X.4.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY with same type" +rule "X.4.0: Remove Entity of type RECOMMENDATION when text range equals ENTITY with same type" salience 256 when $entity: TextEntity($type: type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(intersects($entity), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(getTextRange().equals($entity.getTextRange()), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then $entity.addEngines($recommendation.getEngines()); - $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY with same type"); + $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when text range equals ENTITY with same type"); retract($recommendation); end // Rule unit: X.5 -rule "X.5.0: Remove Entity of type RECOMMENDATION when contained by ENTITY" +rule "X.5.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY" salience 256 when $entity: TextEntity((entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(containedBy($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(intersects($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then - $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when contained by ENTITY"); + $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY"); + retract($recommendation); + end + +rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATION" + salience 256 + when + $entity: TextEntity($type: type, entityType == EntityType.RECOMMENDATION, active()) + $recommendation: TextEntity(containedBy($entity), type != $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + then + $recommendation.remove("X.5.1", "remove Entity of type RECOMMENDATION when contained by RECOMMENDATION"); retract($recommendation); end 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 e0a31a54..3a4a82c9 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 @@ -300,26 +300,36 @@ rule "X.3.0: Remove Entity of type RECOMMENDATION when contained by FALSE_RECOMM // Rule unit: X.4 -rule "X.4.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY with same type" +rule "X.4.0: Remove Entity of type RECOMMENDATION when text range equals ENTITY with same type" salience 256 when $entity: TextEntity($type: type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(intersects($entity), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(getTextRange().equals($entity.getTextRange()), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then $entity.addEngines($recommendation.getEngines()); - $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY with same type"); + $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when text range equals ENTITY with same type"); retract($recommendation); end // Rule unit: X.5 -rule "X.5.0: Remove Entity of type RECOMMENDATION when contained by ENTITY" +rule "X.5.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY" salience 256 when $entity: TextEntity((entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(containedBy($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(intersects($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then - $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when contained by ENTITY"); + $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY"); + retract($recommendation); + end + +rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATION" + salience 256 + when + $entity: TextEntity($type: type, entityType == EntityType.RECOMMENDATION, active()) + $recommendation: TextEntity(containedBy($entity), type != $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + then + $recommendation.remove("X.5.1", "remove Entity of type RECOMMENDATION when contained by RECOMMENDATION"); retract($recommendation); end 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 cbf1002e..ae535878 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 @@ -410,26 +410,36 @@ rule "X.3.0: Remove Entity of type RECOMMENDATION when contained by FALSE_RECOMM // Rule unit: X.4 -rule "X.4.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY with same type" +rule "X.4.0: Remove Entity of type RECOMMENDATION when text range equals ENTITY with same type" salience 256 when $entity: TextEntity($type: type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(intersects($entity), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(getTextRange().equals($entity.getTextRange()), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then $entity.addEngines($recommendation.getEngines()); - $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY with same type"); + $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when text range equals ENTITY with same type"); retract($recommendation); end // Rule unit: X.5 -rule "X.5.0: Remove Entity of type RECOMMENDATION when contained by ENTITY" +rule "X.5.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY" salience 256 when $entity: TextEntity((entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(containedBy($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(intersects($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then - $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when contained by ENTITY"); + $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY"); + retract($recommendation); + end + +rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATION" + salience 256 + when + $entity: TextEntity($type: type, entityType == EntityType.RECOMMENDATION, active()) + $recommendation: TextEntity(containedBy($entity), type != $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + then + $recommendation.remove("X.5.1", "remove Entity of type RECOMMENDATION when contained by RECOMMENDATION"); retract($recommendation); end 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 349f0bc5..b2dcd6c4 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 @@ -326,26 +326,36 @@ rule "X.3.0: Remove Entity of type RECOMMENDATION when contained by FALSE_RECOMM // Rule unit: X.4 -rule "X.4.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY with same type" +rule "X.4.0: Remove Entity of type RECOMMENDATION when text range equals ENTITY with same type" salience 256 when $entity: TextEntity($type: type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(intersects($entity), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(getTextRange().equals($entity.getTextRange()), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then $entity.addEngines($recommendation.getEngines()); - $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY with same type"); + $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when text range equals ENTITY with same type"); retract($recommendation); end // Rule unit: X.5 -rule "X.5.0: Remove Entity of type RECOMMENDATION when contained by ENTITY" +rule "X.5.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY" salience 256 when $entity: TextEntity((entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(containedBy($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(intersects($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then - $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when contained by ENTITY"); + $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY"); + retract($recommendation); + end + +rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATION" + salience 256 + when + $entity: TextEntity($type: type, entityType == EntityType.RECOMMENDATION, active()) + $recommendation: TextEntity(containedBy($entity), type != $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + then + $recommendation.remove("X.5.1", "remove Entity of type RECOMMENDATION when contained by RECOMMENDATION"); retract($recommendation); end 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 0c6799e9..52f95ac1 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 @@ -1525,26 +1525,38 @@ rule "X.3.0: Remove Entity of type RECOMMENDATION when contained by FALSE_RECOMM // Rule unit: X.4 -rule "X.4.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY with same type" +rule "X.4.0: Remove Entity of type RECOMMENDATION when text range equals ENTITY with same type" salience 256 when $entity: TextEntity($type: type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(intersects($entity), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(getTextRange().equals($entity.getTextRange()), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then $entity.addEngines($recommendation.getEngines()); - $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY with same type"); + $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when text range equals ENTITY with same type"); retract($recommendation); end // Rule unit: X.5 -rule "X.5.0: Remove Entity of type RECOMMENDATION when contained by ENTITY" +rule "X.5.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY" salience 256 when $entity: TextEntity((entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(containedBy($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(intersects($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then - $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when contained by ENTITY"); + $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY"); + retract($recommendation); + end + + +// Rule unit: X.5 +rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATION" + salience 256 + when + $entity: TextEntity($type: type, entityType == EntityType.RECOMMENDATION, active()) + $recommendation: TextEntity(containedBy($entity), type != $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + then + $recommendation.remove("X.5.1", "remove Entity of type RECOMMENDATION when contained by RECOMMENDATION"); retract($recommendation); end 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 72a2dcd0..6b11c0f4 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 @@ -1492,26 +1492,38 @@ rule "X.3.0: Remove Entity of type RECOMMENDATION when contained by FALSE_RECOMM // Rule unit: X.4 -rule "X.4.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY with same type" +rule "X.4.0: Remove Entity of type RECOMMENDATION when text range equals ENTITY with same type" salience 256 when $entity: TextEntity($type: type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(intersects($entity), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(getTextRange().equals($entity.getTextRange()), type == $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then $entity.addEngines($recommendation.getEngines()); - $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY with same type"); + $recommendation.remove("X.4.0", "remove Entity of type RECOMMENDATION when text range equals ENTITY with same type"); retract($recommendation); end // Rule unit: X.5 -rule "X.5.0: Remove Entity of type RECOMMENDATION when contained by ENTITY" +rule "X.5.0: Remove Entity of type RECOMMENDATION when intersected by ENTITY" salience 256 when $entity: TextEntity((entityType == EntityType.ENTITY || entityType == EntityType.HINT), active()) - $recommendation: TextEntity(containedBy($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + $recommendation: TextEntity(intersects($entity), entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) then - $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when contained by ENTITY"); + $recommendation.remove("X.5.0", "remove Entity of type RECOMMENDATION when intersected by ENTITY"); + retract($recommendation); + end + + +// Rule unit: X.5 +rule "X.5.1: Remove Entity of type RECOMMENDATION when contained by RECOMMENDATION" + salience 256 + when + $entity: TextEntity($type: type, entityType == EntityType.RECOMMENDATION, active()) + $recommendation: TextEntity(containedBy($entity), type != $type, entityType == EntityType.RECOMMENDATION, !hasManualChanges(), active()) + then + $recommendation.remove("X.5.1", "remove Entity of type RECOMMENDATION when contained by RECOMMENDATION"); retract($recommendation); end diff --git a/redaction-service-v1/rules-management/src/main/resources/default_rule_identifiers.txt b/redaction-service-v1/rules-management/src/main/resources/default_rule_identifiers.txt index 730c694c..f31074ae 100644 --- a/redaction-service-v1/rules-management/src/main/resources/default_rule_identifiers.txt +++ b/redaction-service-v1/rules-management/src/main/resources/default_rule_identifiers.txt @@ -5,6 +5,7 @@ X.2.0 X.3.0 X.4.0 X.5.0 +X.5.1 X.6.* FA.*.* LDS.*.* \ No newline at end of file diff --git a/redaction-service-v1/rules-management/src/main/resources/default_rule_identifiers_dm.txt b/redaction-service-v1/rules-management/src/main/resources/default_rule_identifiers_dm.txt index 7f2c2e5e..f021f041 100644 --- a/redaction-service-v1/rules-management/src/main/resources/default_rule_identifiers_dm.txt +++ b/redaction-service-v1/rules-management/src/main/resources/default_rule_identifiers_dm.txt @@ -4,6 +4,7 @@ X.2.0 X.3.0 X.4.0 X.5.0 +X.5.1 X.7.0 FA.*.* LDS.*.* \ No newline at end of file