RED-7679: Updated table demo rules for entities and components

This commit is contained in:
Ali Oezyetimoglu 2023-10-31 08:37:06 +01:00
parent 0ba9c90f92
commit 856ae9e739
3 changed files with 77 additions and 16 deletions

View File

@ -435,12 +435,11 @@ public class ComponentCreationService {
.entrySet()
.stream()
.sorted(Comparator.comparingInt(Map.Entry::getKey))
// .map(Map.Entry::getValue)
.forEach(integerListEntry -> {
var rowNumber = integerListEntry.getKey();
var entitiesInSameRow = integerListEntry.getValue();
create(ruleIdentifier,
name + rowNumber,
name + " " + rowNumber,
entitiesInSameRow.stream().sorted(EntityComparators.first()).map(Entity::getValue).collect(Collectors.joining(", ")),
valueDescription,
entitiesInSameRow);

View File

@ -139,28 +139,26 @@ rule "TAB.4.0: Combined Columns Extraction - Sex and Dosage"
when
FileAttribute(label == "OECD Number", valueEqualsAnyOf("425"))
$section: Section(getHeadline().containsString("Combined Columns"))
$table: Table(hasHeader("Sex"), hasHeader("Dosage (mg/kg bw)")) from $section.getParent().streamAllSubNodesOfType(NodeType.TABLE).toList()
$maleCells: TableCell($row: row, containsAnyWordIgnoreCase("Male")) from $table.streamTableCellsWithHeader("Sex").toList()
$dosageCells: TableCell($row == row) from $table.streamTableCellsWithHeader("Dosage").toList()
$table: Table(hasHeader("Dosage (mg/kg bw)")) from $section.getParent().streamAllSubNodesOfType(NodeType.TABLE).toList()
then
entityCreationService.bySemanticNode($maleCells, "combined_male_dosage", EntityType.ENTITY)
.ifPresent(entity -> entity.apply("TAB.4.0", "Dosage combined in row with male"));
entityCreationService.bySemanticNode($dosageCells, "combined_male_dosage", EntityType.ENTITY)
.ifPresent(entity -> entity.apply("TAB.4.0", "Dosage combined in row with male"));
$table.streamTableCellsWithHeader("Dosage (mg/kg bw)")
.map(tableCell -> entityCreationService.bySemanticNode(tableCell, "dose_mortality_dose", EntityType.ENTITY))
.filter(Optional::isPresent)
.map(Optional::get)
.forEach(redactionEntity -> redactionEntity.apply("TAB.4.0", "Dose Mortality dose found."));
end
rule "TAB.4.1: Combined Columns Extraction - Sex and Mortality"
when
FileAttribute(label == "OECD Number", valueEqualsAnyOf("425"))
$section: Section(getHeadline().containsString("Combined Columns"))
$table: Table(hasHeader("Sex"), hasHeader("Mortality")) from $section.getParent().streamAllSubNodesOfType(NodeType.TABLE).toList()
$femaleCells: TableCell($row: row, containsAnyWordIgnoreCase("Female")) from $table.streamTableCellsWithHeader("Sex").toList()
$mortalityCells: TableCell($row == row) from $table.streamTableCellsWithHeader("Mortality").toList()
$table: Table(hasHeader("Mortality")) from $section.getParent().streamAllSubNodesOfType(NodeType.TABLE).toList()
then
entityCreationService.bySemanticNode($femaleCells, "combined_female_mortality", EntityType.ENTITY)
.ifPresent(entity -> entity.apply("TAB.4.1", "Mortality combined in row with female"));
entityCreationService.bySemanticNode($mortalityCells, "combined_female_mortality", EntityType.ENTITY)
.ifPresent(entity -> entity.apply("TAB.4.1", "Mortality combined in row with female"));
$table.streamTableCellsWithHeader("Mortality")
.map(tableCell -> entityCreationService.bySemanticNode(tableCell, "dose_mortality", EntityType.ENTITY))
.filter(Optional::isPresent)
.map(Optional::get)
.forEach(redactionEntity -> redactionEntity.apply("TAB.4.1", "Dose Mortality found."));
end
rule "TAB.5.0: Targeted cell extraction"

View File

@ -45,6 +45,70 @@ declare GuidelineMapping
guideline: String
end
//------------------------------------ Demo Components rules ------------------------------------
rule "FullTable.1.1: All rows of matching table"
when
$tableRowValues: List() from collect (Entity(type == "full_table_row"))
then
componentCreationService.joiningFromSameTableRow("FullTable.1.1", "Full Table", $tableRowValues);
end
rule "IndivRowExtr.1.2: Individual rows of table"
when
$oecdNumber: String() from List.of("425")
FileAttribute(label == "OECD Number", value == $oecdNumber)
$clinicalSigns: List() from collect (Entity(type == "clinical_signs"))
then
componentCreationService.joining("IndivRowExtr.1.2", "Extracted experiment", $clinicalSigns, "\n");
end
rule "IndivColExtr.1.3: Individual column of table"
when
$tableColValues: List() from collect (Entity(type == "dosages"))
then
componentCreationService.joining("IndivColExtr.1.3", "Dosages", $tableColValues);
end
/*
rule "CombColExtr.2.1: Combined Columns Extraction"
when
$oecdNumber: String() from List.of("425")
FileAttribute(label == "OECD Number", value == $oecdNumber)
$doseMortalities: List() from collect (Entity(type == "dose_mortality" || type == "dose_mortality_dose"))
then
componentCreationService.joiningFromSameTableRow("DoseMortality.0.0", "Dose Mortality", $doseMortalities);
end
*/
rule "ValueExtrRef.2.2: Cells containing dose for survived males"
when
$tableValues: List() from collect (Entity(type == "doses_mg_kg_bw"))
then
componentCreationService.joining("ValueExtrRef.2.2", "Doses", $tableValues);
end
rule "AdvTableExtr.2.3: Cells containing dose for survived males"
when
$tableValues: List() from collect (Entity(type == "experiment_female_survived"))
then
componentCreationService.joining("AdvTableExtr.2.3", "Experiment Female Survived", $tableValues);
end
rule "EntityBasedExtr.2.4: Cells containing dose for survived males"
when
$tableValues: List() from collect (Entity(type == "study_design"))
then
componentCreationService.joiningFromSameTableRow("EntityBasedExtr.2.4", "Vertebrate in row", $tableValues);
end
//------------------------------------ Default Components rules ------------------------------------
rule "StudyTitle.0.0: First Title found"