Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat raw IRI as an OWLClass in logical template cells #1211

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,14 @@ protected static OWLClassExpression tryParse(
// If we have a checker, try to get the class by label
// This allows class labels with single quotes
expr = checker.getOWLClass(content, false);
if (expr == null) {
// If not found by label, is it just an IRI?
IRI iri = IRI.create(content);
jamesaoverton marked this conversation as resolved.
Show resolved Hide resolved
if (iri != null) {
// If so, create a new class for this IRI.
expr = checker.getOWLClass(content, true);
}
}
}
if (expr == null) {
// If not found by label, try to parse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void testGetClassExpressions() throws Exception {
ManchesterOWLSyntaxClassExpressionParser parser =
new ManchesterOWLSyntaxClassExpressionParser(dataFactory, checker);

// Check CURIE
String template = "C part_of some %";
String value = "obo:UBERON_0000467";
Set<OWLClassExpression> expressions =
Expand All @@ -148,6 +149,24 @@ public void testGetClassExpressions() throws Exception {
for (OWLClassExpression expr : expressions) {
assertEquals(exprMatch.toString(), expr.toString());
}

// Check raw IRI
value = "http://purl.obolibrary.org/obo/UBERON_0000467";
expressions = TemplateHelper.getClassExpressions("", parser, template, value, 0, 0);
if (expressions.size() != 1) {
fail(String.format("Expected exactly 1 expression, got %d", expressions.size()));
}
for (OWLClassExpression expr : expressions) {
assertEquals(exprMatch.toString(), expr.toString());
}

// Check that gibberish fails
try {
value = "http.purl.obolibrary.org/obo/UBERON_0000467";
expressions = TemplateHelper.getClassExpressions("", parser, template, value, 0, 0);
fail("Gibberish value should not be parsed as Manchester expression");
} catch (Exception e) {
}
}

/**
Expand Down
Loading