Skip to content

Commit

Permalink
Update GNP Reader version(s) to avoid exception with empty zones.
Browse files Browse the repository at this point in the history
PMID37632434 has a complete empty abstract section: <AbstractText Label="INTRODUCTION" NlmCategory="BACKGROUND"/> and no text in the abstract at all. That caused an exception when checking for empty text because `getCoveredtext()` failed.
  • Loading branch information
khituras committed Feb 13, 2024
1 parent e75cbd1 commit 4cd8ff6
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 74 deletions.
2 changes: 1 addition & 1 deletion jcore-biosem-ae/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"maven-artifact": {
"artifactId": "jcore-biosem-ae",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.2"
},
"name": "JCoRe BioSem Event Annotator"
}
2 changes: 1 addition & 1 deletion jcore-db-checkpoint-ae/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"maven-artifact": {
"artifactId": "jcore-db-checkpoint-ae",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.3"
},
"name": "JCoRe Database Checkpoint AE"
}
2 changes: 1 addition & 1 deletion jcore-db-reader/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"maven-artifact": {
"artifactId": "jcore-db-reader",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.3"
},
"name": "JCoRe Database Reader"
}
2 changes: 1 addition & 1 deletion jcore-elasticsearch-consumer/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"maven-artifact": {
"artifactId": "jcore-elasticsearch-consumer",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.3"
},
"name": "JCoRe ElasticSearch Consumer"
}
2 changes: 1 addition & 1 deletion jcore-gnormplus-ae/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"maven-artifact": {
"artifactId": "jcore-gnormplus-ae",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.8-SNAPSHOT"
},
"name": "JCoRe GNormPlus Annotator"
}
6 changes: 3 additions & 3 deletions jcore-gnormplus-ae/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<version>2.6.1</version>
</parent>

<version>2.6.7</version>
<version>2.6.8-SNAPSHOT</version>

<dependencies>
<dependency>
Expand All @@ -24,12 +24,12 @@
<dependency>
<groupId>de.julielab</groupId>
<artifactId>jcore-gnp-bioc-writer</artifactId>
<version>2.6.3</version>
<version>[2.6.3,2.7)</version>
</dependency>
<dependency>
<groupId>de.julielab</groupId>
<artifactId>jcore-gnp-bioc-reader</artifactId>
<version>2.6.3</version>
<version>[2.6.3, 2.7)</version>
</dependency>
<dependency>
<groupId>de.julielab</groupId>
Expand Down
2 changes: 1 addition & 1 deletion jcore-gnp-bioc-reader/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"maven-artifact": {
"artifactId": "jcore-gnp-bioc-reader",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.3"
},
"name": "JCoRe GNormPlus BioC Reader"
}
2 changes: 1 addition & 1 deletion jcore-gnp-bioc-writer/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"maven-artifact": {
"artifactId": "jcore-gnp-bioc-writer",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.4-SNAPSHOT"
},
"name": "JCoRe GNormPlus BioC Writer"
}
2 changes: 1 addition & 1 deletion jcore-gnp-bioc-writer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<artifactId>jcore-base</artifactId>
<version>2.6.1</version>
</parent>
<version>2.6.3</version>
<version>2.6.4-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,66 +34,71 @@ public BioCDocument populate(JCas jCas) {
AnnotationIndex<Zone> zoneIndex = jCas.getAnnotationIndex(Zone.type);
int annotationId = 0;
for (Zone z : zoneIndex) {
// skip empty zones
if (z.getCoveredText().isBlank())
continue;
BioCPassage p = null;
if (z instanceof Title) {
Title t = (Title) z;
String titleType;
String titleTypeString = t.getTitleType();
if (titleTypeString == null)
titleTypeString = "other";
switch (titleTypeString) {
case "document":
titleType = "title";
break;
case "section":
titleType = "section_title";
break;
case "figure":
titleType = "figure_title";
break;
case "table":
titleType = "table_title";
break;
case "abstractSection":
// abstract sections are part of the AbstractText which is handled below
titleType = "null";
break;
case "other":
titleType = "other_title";
break;
default:
log.debug("Unhandled title type {}", titleTypeString);
titleType = "other_title";
break;
}
if (titleType != null) {
p = getPassageForAnnotation(t);
p.putInfon("type", titleType);
try {
// skip empty zones
if (z.getEnd() - z.getBegin() <= 0 || z.getCoveredText().isBlank())
continue;
BioCPassage p = null;
if (z instanceof Title) {
Title t = (Title) z;
String titleType;
String titleTypeString = t.getTitleType();
if (titleTypeString == null)
titleTypeString = "other";
switch (titleTypeString) {
case "document":
titleType = "title";
break;
case "section":
titleType = "section_title";
break;
case "figure":
titleType = "figure_title";
break;
case "table":
titleType = "table_title";
break;
case "abstractSection":
// abstract sections are part of the AbstractText which is handled below
titleType = "null";
break;
case "other":
titleType = "other_title";
break;
default:
log.debug("Unhandled title type {}", titleTypeString);
titleType = "other_title";
break;
}
if (titleType != null) {
p = getPassageForAnnotation(t);
p.putInfon("type", titleType);
doc.addPassage(p);
}
} else if (z instanceof AbstractText) {
AbstractText at = (AbstractText) z;
p = getPassageForAnnotation(at);
p.putInfon("type", "abstract");
doc.addPassage(p);
} else if (z instanceof Paragraph) {
Paragraph pa = (Paragraph) z;
p = getPassageForAnnotation(pa);
p.putInfon("type", "paragraph");
doc.addPassage(p);
} else if (z instanceof Caption) {
Caption c = (Caption) z;
p = getPassageForAnnotation(c);
if (c.getCaptionType() == null)
throw new IllegalArgumentException("The captionType feature is null for " + c);
p.putInfon("type", c.getCaptionType());
doc.addPassage(p);
}
} else if (z instanceof AbstractText) {
AbstractText at = (AbstractText) z;
p = getPassageForAnnotation(at);
p.putInfon("type", "abstract");
doc.addPassage(p);
} else if (z instanceof Paragraph) {
Paragraph pa = (Paragraph) z;
p = getPassageForAnnotation(pa);
p.putInfon("type", "paragraph");
doc.addPassage(p);
} else if (z instanceof Caption) {
Caption c = (Caption) z;
p = getPassageForAnnotation(c);
if (c.getCaptionType() == null)
throw new IllegalArgumentException("The captionType feature is null for " + c);
p.putInfon("type", c.getCaptionType());
doc.addPassage(p);
}
if (addGenes) {
annotationId = addGenesToPassage(jCas, z, p, annotationId);
if (addGenes) {
annotationId = addGenesToPassage(jCas, z, p, annotationId);
}
} catch (Exception e) {
log.error("Exception occurred with Zone annotation {}", z);
throw e;
}
}
return doc;
Expand Down
2 changes: 1 addition & 1 deletion jcore-neo4j-relations-consumer/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"maven-artifact": {
"artifactId": "jcore-neo4j-relations-consumer",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.2"
},
"name": "JCoRe Neo4j Relations Consumer"
}
2 changes: 1 addition & 1 deletion jcore-pmc-db-reader/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"maven-artifact": {
"artifactId": "jcore-pmc-db-reader",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.3"
},
"name": "JCoRe PubMed Central DB Reader"
}
2 changes: 1 addition & 1 deletion jcore-xmi-db-reader/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"maven-artifact": {
"artifactId": "jcore-xmi-db-reader",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.3"
},
"name": "JCoRe XMI Database Reader"
}
2 changes: 1 addition & 1 deletion jcore-xmi-db-writer/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"maven-artifact": {
"artifactId": "jcore-xmi-db-writer",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.3"
},
"name": "JCoRe XMI Database Writer"
}
2 changes: 1 addition & 1 deletion jcore-xml-db-reader/component.meta
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"maven-artifact": {
"artifactId": "jcore-xml-db-reader",
"groupId": "de.julielab",
"version": "2.6.1"
"version": "2.6.3"
},
"name": "JCoRe XML Database Reader"
}

0 comments on commit 4cd8ff6

Please sign in to comment.