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 5ca8ff74..31a7bc4d 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 @@ -265,9 +265,9 @@ rule "3: Experimental Completion Date" $section: Section( (hasEntitiesOfType("species") || hasEntitiesOfType("strain")) && !( - getHeadline().containsString("test system") - || getHeadline().containsString("animals") - || getHeadline().containsString("specification") + anyHeadlineContainsStringIgnoreCase("test system") + || anyHeadlineContainsStringIgnoreCase("animals") + || anyHeadlineContainsStringIgnoreCase("specification") ) ) then @@ -304,9 +304,9 @@ rule "5: Strain" hasEntitiesOfType("species") && hasEntitiesOfType("strain") && ( - getHeadline().containsStringIgnoreCase("test system") - || getHeadline().containsStringIgnoreCase("animals") - || getHeadline().containsStringIgnoreCase("specification") + anyHeadlineContainsStringIgnoreCase("test system") + || anyHeadlineContainsStringIgnoreCase("animals") + || anyHeadlineContainsStringIgnoreCase("specification") ) ) then @@ -681,12 +681,11 @@ rule "13: Clinical Signs" && !getHeadline().containsString("TABLE") ) then - entityCreationService.bySemanticNode($section, "clinical_signs", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Clinical Signs found"); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("13"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "clinical_signs", EntityType.ENTITY, $section); + entity.setRedactionReason("Clinical Signs found"); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("13"); end @@ -781,12 +780,11 @@ rule "19: Necropsy findings" && !getHeadline().containsString("Appendix") ) then - entityCreationService.bySemanticNode($section, "necropsy_findings", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Necropsy section found"); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("19"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "necropsy_findings", EntityType.ENTITY, $section); + entity.setRedactionReason("Necropsy section found"); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("19"); end @@ -805,12 +803,12 @@ rule "22: Clinical observations" ) then - entityCreationService.bySemanticNode($section, "clinical_observations", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Clinical observations section found"); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("22"); - }); + + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "clinical_observations", EntityType.ENTITY, $section); + entity.setRedactionReason("Clinical observations section found"); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("22"); end @@ -878,13 +876,11 @@ rule "23: Bodyweight changes" && !getHeadline().containsString("TABLE") ) then - - entityCreationService.bySemanticNode($section, "bodyweight_changes", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Bodyweight section found"); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("23"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "bodyweight_changes", EntityType.ENTITY, $section); + entity.setRedactionReason("Bodyweight section found"); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("23"); end @@ -895,13 +891,11 @@ rule "24: Study Design" getHeadline().containsString("study design") ) then - - entityCreationService.bySemanticNode($section, "study_design", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Study design section found"); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("24"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "study_design", EntityType.ENTITY, $section); + entity.setRedactionReason("Study design section found"); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("24"); end @@ -916,13 +910,11 @@ rule "25: Results and Conclusion (406, 428, 438, 439, 474 & 487)" !getHeadline().containsString("TABLE") && !getHeadline().containsString("DISCUSSION") && !getHeadline().containsString("CONCLUSIONS") && !getHeadline().containsString("Interpretation") && !getHeadline().containsString("Viability")) then - - entityCreationService.bySemanticNode($section, "results_and_conclusion", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Results and Conclusion found"); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("25"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "results_and_conclusion", EntityType.ENTITY, $section); + entity.setRedactionReason("Results and Conclusion found"); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("25"); end @@ -934,12 +926,11 @@ rule "26: Detailing (404 & 405)" getHeadline().containsString("Results") && !getHeadline().containsString("Evaluation") && !getHeadline().containsString("study") ) then - entityCreationService.bySemanticNode($section, "detailing", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Detailing found"); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("26"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "detailing", EntityType.ENTITY, $section); + entity.setRedactionReason("Detailing found"); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("26"); end @@ -952,12 +943,11 @@ rule "32: Preliminary Test Results (429)" || getHeadline().containsString("Pre-Experiment")) ) then - entityCreationService.bySemanticNode($section, "preliminary_test_results", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Preliminary Test Results found"); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("32"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "preliminary_test_results", EntityType.ENTITY, $section); + entity.setRedactionReason("Preliminary Test Results found"); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("32"); end @@ -966,12 +956,11 @@ rule "33: Test Results (429)" FileAttribute(label == "OECD Number", value == "429") $section: Section((getHeadline().containsString("RESULTS AND DISCUSSION") || getHeadline().containsString("Estimation of the proliferative response of lymph node cells") || getHeadline().containsString("Results in the Main Experiment"))) then - entityCreationService.bySemanticNode($section, "test_results", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Test Results found"); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("33"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "test_results", EntityType.ENTITY, $section); + entity.setRedactionReason("Test Results found"); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("33"); end @@ -1148,12 +1137,11 @@ rule "39: Dilution of the test substance" && containsString("dilution") ) then - entityCreationService.bySemanticNode($section, "dilution", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Dilution found."); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("39"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "dilution", EntityType.ENTITY, $section); + entity.setRedactionReason("Dilution found."); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("39"); end @@ -1168,12 +1156,11 @@ rule "40: Positive Control" ) ) then - entityCreationService.bySemanticNode($section, "positive_control", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Positive control found."); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("40"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "positive_control", EntityType.ENTITY, $section); + entity.setRedactionReason("Positive control found."); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("40"); end @@ -1237,12 +1224,11 @@ rule "44: Results (Main Study)" ) ) then - entityCreationService.bySemanticNode($section, "results_(main_study)", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Results for main study found."); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("44"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "results_(main_study)", EntityType.ENTITY, $section); + entity.setRedactionReason("Results for main study found."); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("44"); end @@ -1253,12 +1239,11 @@ rule "45: Doses (mg/kg bodyweight)" getHeadline().containsString("study design") ) then - entityCreationService.bySemanticNode($section, "doses_(mg_kg_bw)", EntityType.ENTITY).ifPresent(entity -> { - entity.setRedactionReason("Doses per bodyweight information found"); - entity.setLegalBasis("n-a"); - entity.setRedaction(true); - entity.addMatchedRule("45"); - }); + var entity = entityCreationService.byBoundary(Boundary.merge($section.streamAllSubNodesOfType(NodeType.PARAGRAPH).map(SemanticNode::getBoundary).toList()), "doses_(mg_kg_bw)", EntityType.ENTITY, $section); + entity.setRedactionReason("Doses per bodyweight information found"); + entity.setLegalBasis("n-a"); + entity.setRedaction(true); + entity.addMatchedRule("45"); end