From 7dfaf604e7fb0d09e66a1688b1657006a3e92156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominique=20Eifl=C3=A4nder?= Date: Mon, 25 Jan 2021 11:20:35 +0100 Subject: [PATCH] Fixed recognize rules and exceptions for redactAndRecommend, fixed wrong order of rules(published information) --- .../v1/server/redaction/model/Section.java | 3 +-- .../src/test/resources/drools/allAuthors.drl | 20 ++++++++-------- .../src/test/resources/drools/rules.drl | 24 +++++++++---------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/redaction/model/Section.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/redaction/model/Section.java index 47ac8d7f..0e53f25f 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/redaction/model/Section.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/redaction/model/Section.java @@ -211,9 +211,8 @@ public class Section { while (matcher.find()) { String match = matcher.group(group); if (StringUtils.isNotBlank(match) && match.length() >= 3) { - Set found = findEntities(match.trim(), asType, false, false, ruleNumber, reason, legalBasis); - addNewerToEntities(found); localDictionaryAdds.computeIfAbsent(RECOMMENDATION_PREFIX + asType, (x) -> new HashSet<>()).add(match); + localDictionaryAdds.computeIfAbsent(asType, (x) -> new HashSet<>()).add(match); } } } diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/allAuthors.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/allAuthors.drl index 73676d3d..cef5da6c 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/allAuthors.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/allAuthors.drl @@ -39,16 +39,7 @@ rule "4: Do not redact Names and Addresses if no redaction Indicator is containe end -rule "5: Do not redact Names and Addresses if no redaction Indicator is contained" - when - Section(matchesType("vertebrate"), matchesType("published_information")) - then - section.redactNot("CBI_author", 4, "Vertebrate and Published Information found"); - section.redactNot("CBI_address", 5, "Vertebrate and Published Information found"); - end - - -rule "6: Redact Names and Addresses if no_redaction_indicator and redaction_indicator is contained" +rule "5: Redact Names and Addresses if no_redaction_indicator and redaction_indicator is contained" when Section(matchesType("vertebrate"), matchesType("no_redaction_indicator"), matchesType("redaction_indicator")) then @@ -56,6 +47,15 @@ rule "6: Redact Names and Addresses if no_redaction_indicator and redaction_indi end +rule "6: Do not redact Names and Addresses if no redaction Indicator is contained" + when + Section(matchesType("vertebrate"), matchesType("published_information")) + then + section.redactNot("CBI_author", 6, "Vertebrate and Published Information found"); + section.redactNot("CBI_address", 6, "Vertebrate and Published Information found"); + end + + rule "7: Not redacted because Vertebrate Study = N" when Section(rowEquals("Vertebrate study Y/N", "N") || rowEquals("Vertebrate study Y/N", "No")) 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 fe8d75fb..df75bbe9 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 @@ -34,21 +34,21 @@ rule "3: Do not redact Names and Addresses if no redaction Indicator is containe end -rule "4: Do not redact Names and Addresses if no redaction Indicator is contained" - when - Section(matchesType("vertebrate"), matchesType("published_information")) - then - section.redactNot("CBI_author", 4, "Vertebrate and Published Information found"); - section.redactNot("CBI_address", 4, "Vertebrate and Published Information found"); - end - - -rule "5: Redact Names and Addresses if no_redaction_indicator and redaction_indicator is contained" +rule "4: Redact Names and Addresses if no_redaction_indicator and redaction_indicator is contained" when Section(matchesType("vertebrate"), matchesType("no_redaction_indicator"), matchesType("redaction_indicator")) then - section.redact("CBI_author", 5, "Vertebrate and Redaction Indicator found", "Reg (EC) No 1107/2009 Art. 63 (2g)"); - section.redact("CBI_address", 5, "Vertebrate and Redaction Indicator found", "Reg (EC) No 1107/2009 Art. 63 (2g)"); + section.redact("CBI_author", 4, "Vertebrate and Redaction Indicator found", "Reg (EC) No 1107/2009 Art. 63 (2g)"); + section.redact("CBI_address", 4, "Vertebrate and Redaction Indicator found", "Reg (EC) No 1107/2009 Art. 63 (2g)"); + end + + +rule "5: Do not redact Names and Addresses if no redaction Indicator is contained" + when + Section(matchesType("vertebrate"), matchesType("published_information")) + then + section.redactNot("CBI_author", 5, "Vertebrate and Published Information found"); + section.redactNot("CBI_address", 5, "Vertebrate and Published Information found"); end