Skip to content

Commit

Permalink
Update curie formation logic (#750)
Browse files Browse the repository at this point in the history
* - Update curie formation logic

* - Improve code logic

* - Improve code logic to handle edge cases
  • Loading branch information
haideriqbal authored Oct 17, 2024
1 parent 4f3b427 commit 55fa274
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,21 @@ public static void annotateShortForms(OntologyGraph graph) {
}

String shortForm = extractShortForm(graph, ontologyBaseUris, preferredPrefix, c.uri);
String curie = shortForm.replaceFirst("_", ":");

/*
CURIEs are formed by following rules:
If there is only one underscore "_" AND the characters after the underscore are numbers then replace the underscore with colon ":"
If there is only one underscore "_" and the characters after the underscore are not just numbers then just keep the curie same as shortform
If there are multiple underscore but has only digits after the last underscore then the code replaces the last underscore with a colon
*/

String curie = shortForm.replaceFirst("_(\\d+)$", ":$1");
c.properties.addProperty("shortForm", PropertyValueLiteral.fromString(shortForm));
c.properties.addProperty("curie", PropertyValueLiteral.fromString(curie));
}
}
long endTime3 = System.nanoTime();
logger.info("annotate short forms: {}", ((endTime3 - startTime3) / 1000 / 1000 / 1000));


}

private static String extractShortForm(OntologyGraph graph, Set<String> ontologyBaseUris, String preferredPrefix,
Expand Down

0 comments on commit 55fa274

Please sign in to comment.