Skip to content

Commit

Permalink
Merge pull request #927 from hkir-dev/issue924
Browse files Browse the repository at this point in the history
Fix Issue: SPLIT fails with owl:NamedIndividual #924
  • Loading branch information
jamesaoverton authored Nov 8, 2021
2 parents 1171b0d + 262853f commit 7716a48
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix `deprecated_class_reference` [`report`] query [#902]
- Fix error handling for JSON conversion [#907]
- Fix handling of property chains when removing/filtering base axioms in [#914]
- Fix SPLIT unpacking in named individuals in [`template`] [#924]

### Changed
- Do not allow malformed IRIs to be returned by `IOHelper` [#882]
Expand Down Expand Up @@ -276,6 +277,7 @@ First official release of ROBOT!
[`template`]: http://robot.obolibrary.org/template
[`validate`]: http://robot.obolibrary.org/validate

[#924]: https://github.com/ontodev/robot/issues/924
[#914]: https://github.com/ontodev/robot/pull/914
[#907]: https://github.com/ontodev/robot/pull/907
[#902]: https://github.com/ontodev/robot/pull/902
Expand Down
4 changes: 4 additions & 0 deletions robot-core/src/main/java/org/obolibrary/robot/Template.java
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,10 @@ private void addIndividualAxioms(IRI iri, List<String> row) throws Exception {

// Handle annotations
if (template.startsWith("A") || template.startsWith("LABEL")) {
if (split != null) {
// Add the split back on for getAnnotations
template = template + " SPLIT=" + split;
}
// Add the annotations to the individual
Set<OWLAnnotation> annotations = getAnnotations(template, value, row, column);
for (OWLAnnotation annotation : annotations) {
Expand Down
30 changes: 30 additions & 0 deletions robot-core/src/test/java/org/obolibrary/robot/TemplateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxClassExpressionParser;
import org.semanticweb.owlapi.model.*;
import org.semanticweb.owlapi.search.EntitySearcher;

/**
* Tests Template class and class methods.
Expand Down Expand Up @@ -156,4 +157,33 @@ public void testParseClass() throws Exception {
TemplateHelper.tryParse("test", checker, parser, label, 0, 0).asOWLClass();
assert actualClass.getIRI().toString().equals(expectedClass.getIRI().toString());
}

/**
* Test named individual with split property.
*
* @throws Exception if entities cannot be found
*/
@Test
public void testNamedIndividualSplit() throws Exception {
Map<String, String> options = TemplateOperation.getDefaultOptions();
IOHelper ioHelper = new IOHelper();
ioHelper.addPrefix("ex", "http://example.com/");

Map<String, List<List<String>>> tables = new LinkedHashMap<>();
String path = "/template-individual-split.csv";
tables.put(path, TemplateHelper.readCSV(this.getClass().getResourceAsStream(path)));

OWLOntology ontology = TemplateOperation.template(null, ioHelper, tables, options);

assertEquals("Count individuals", 1, ontology.getIndividualsInSignature().size());
OWLNamedIndividual namedIndividual = ontology.getIndividualsInSignature().iterator().next();
assertEquals(
"Count annotation properties", 1, ontology.getAnnotationPropertiesInSignature().size());
OWLAnnotationProperty annotationProperty =
ontology.getAnnotationPropertiesInSignature().iterator().next();
assertEquals(
"Count annotation properties of individual",
2,
EntitySearcher.getAnnotationObjects(namedIndividual, ontology, annotationProperty).size());
}
}
3 changes: 3 additions & 0 deletions robot-core/src/test/resources/template-individual-split.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ID,Entity Type,Synonyms
ID,TYPE,A IAO:0000118 SPLIT=|
ex:indv_1,owl:NamedIndividual,synonym 1|synonym 2

0 comments on commit 7716a48

Please sign in to comment.