From 18979d0f33c451acf3605d4e2a8ffa3db00e5b1d Mon Sep 17 00:00:00 2001 From: deiflaender Date: Fri, 14 Jul 2023 12:26:06 +0200 Subject: [PATCH] DM-305: Improved DocuMine rules --- .../test/resources/drools/documine_flora.drl | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) 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 03ba460b..a84efef4 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 @@ -329,20 +329,17 @@ rule "DOC.7.0: study title by document structure" end -//rule "DOC.7.0: study title" -// when -// $section: Section(isOnPage(1) && (containsString("Final Report") || containsString("SPL"))) -// then -// entityCreationService.byRegexWithLineBreaks("(?<=\\n)[\\w\\W]{1,300}(?=\\nFinal Report)", "title", EntityType.ENTITY, $section).findFirst().ifPresent(entity -> { -// entity.apply("DOC.7.0", "Title found", "n-a"); -// }); -// entityCreationService.betweenStrings("TITLE", "DATA REQUIREMENT", "title", EntityType.ENTITY, $section).findFirst().ifPresent(entity -> { -// entity.apply("DOC.7.0", "Title found", "n-a"); -// }); -// entityCreationService.betweenStrings("Laboratories", "SPL", "title", EntityType.ENTITY, $section).findFirst().ifPresent(entity -> { -// entity.apply("DOC.7.0", "Title found", "n-a"); -// }); -// end +rule "DOC.7.1: study title" + when + $table: Table(isOnPage(1), + (containsString("Final Report") || containsString("SPL")), + numberOfRows == 1, + numberOfCols == 1) + then + entityCreationService.byRegexWithLineBreaksIgnoreCase("(?<=\\n)[\\w\\W]{1,300}(?=\\nFinal Report)", "title", EntityType.ENTITY, $table.getCell(0, 0)).findFirst().ifPresent(entity -> { + entity.apply("DOC.7.1", "Title found", "n-a"); + }); + end rule "DOC.8.1: Performing Laboratory (Name)" @@ -574,7 +571,7 @@ rule "DOC.12.0: Guideline Deviation" entityCreationService.byRegexIgnoreCase("(?>Study plan adherence)(.{1,20}deviations.{1,20} to the study plan.{0,50}\\.)\\s", "guideline_deviation", EntityType.ENTITY, 1, $section).forEach(entity -> { entity.apply("DOC.12.0", "Guideline deviation found in text.", "n-a"); }); - entityCreationService.betweenStrings("Deviations from the study plan", "validity of the study.", "guideline_deviation", EntityType.ENTITY, $section).forEach(entity -> { + entityCreationService.betweenStringsIncludeEnd("Deviations from the study plan", "validity of the study.", "guideline_deviation", EntityType.ENTITY, $section).forEach(entity -> { entity.apply("DOC.12.0", "Deviation from the study plan found", "n-a"); }); end @@ -837,6 +834,18 @@ rule "DOC.24.0: Study Design" .forEach(entity -> entity.apply("DOC.24.0", "Study design section found", "n-a")); end + +rule "DOC.24.1: Study Design" + when + Headline(containsStringIgnoreCase("Study Design"), $sectionIdentifier: getSectionIdentifier()) + $headline: Headline(getSectionIdentifier().isChildOf($sectionIdentifier)) + then + entityCreationService.bySemanticNodeParagraphsOnly($headline.getParent(), "study_design", EntityType.ENTITY) + .forEach(entity -> { + entity.apply("DOC.24.1", "Study design section found", "n-a"); + }); + end + /* rule "DOC.24.0: Study Design" when @@ -924,6 +933,17 @@ rule "DOC.33.0: Test Results (429)" .forEach(entity -> entity.apply("DOC.33.0", "Test Results found", "n-a")); end +rule "DOC.33.1: Test Results (429)" + when + Headline(containsStringIgnoreCase("RESULTS AND DISCUSSION"), $sectionIdentifierResultsAndDiscussion: getSectionIdentifier()) + $headline: Headline(getSectionIdentifier().isChildOf($sectionIdentifierResultsAndDiscussion)) + then + entityCreationService.bySemanticNodeParagraphsOnly($headline.getParent(), "test_results", EntityType.ENTITY) + .forEach(entity -> { + entity.apply("DOC.33.1", "Test Results found", "n-a"); + }); + end + rule "DOC.34.0: Approach used (429)" when