Skip to content

Commit

Permalink
- Improve code logic to handle edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
haideriqbal committed Oct 2, 2024
1 parent 4eb0e5f commit 5e161a1
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ public static void annotateShortForms(OntologyGraph graph) {

/*
CURIEs are formed by following rules:
If there are more than one underscore "_" in the shortform just keep the curie same as shortform
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;
if (shortForm.matches("^[^_]+_\\d+$")) {
curie = shortForm.replaceFirst("_", ":");
}
String curie = shortForm.replaceFirst("_(\\d+)$", ":$1");
c.properties.addProperty("shortForm", PropertyValueLiteral.fromString(shortForm));
c.properties.addProperty("curie", PropertyValueLiteral.fromString(curie));
}
Expand Down

0 comments on commit 5e161a1

Please sign in to comment.