Skip to content

Commit 9190638

Browse files
committed
improve curie extraction
1 parent 049fce3 commit 9190638

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

dataload/rdf2json/src/main/java/uk/ac/ebi/rdf2json/annotators/ShortFormAnnotator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ If shortFormExtractionPattern is configured, replace first underscore with colon
4949
*/
5050
String curie;
5151

52-
// If custom shortFormExtractionPattern is used, use simple CURIE rule: replace first underscore with colon
52+
// If custom shortFormExtractionPattern is used, construct CURIE using prefix directly to handle prefixes containing underscores
5353
if (shortFormPattern != null && !shortFormPattern.isEmpty() && shortForm.contains("_")) {
54-
curie = shortForm.replaceFirst("_", ":");
54+
curie = preferredPrefix + ":" + shortForm.substring(preferredPrefix.length() + 1);
5555
} else {
5656
// Default CURIE generation logic
5757
// Pattern for: single underscore, prefix matches preferredPrefix
@@ -61,7 +61,7 @@ If shortFormExtractionPattern is configured, replace first underscore with colon
6161
// Pattern for: multiple underscores, suffix is all digits
6262
String multipleUnderscoresDigitsPattern = "^(.*)_(\\d+)$";
6363
if (shortForm.matches(preferredPrefixPattern)) {
64-
curie = shortForm.replaceFirst("_", ":");
64+
curie = preferredPrefix + ":" + shortForm.substring(preferredPrefix.length() + 1);
6565
} else if (shortForm.matches(singleUnderscoreDigitsPattern)) {
6666
curie = shortForm.replaceFirst("_", ":");
6767
} else if (shortForm.matches(multipleUnderscoresDigitsPattern)) {

0 commit comments

Comments
 (0)