Skip to content

Commit

Permalink
Get the prefixes from ROBOT only once.
Browse files Browse the repository at this point in the history
Obtain the prefixes known to ROBOT only once and then use the same
prefix map everywhere we need it.

The 'getPrefixes()' method of the IOHelper object creates a new map
everytime it is used, so it's better to call it only once.
  • Loading branch information
gouttegd committed Sep 3, 2023
1 parent 5a7bb89 commit b73167c
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public CommandState execute(CommandState state, String[] args) throws Exception

OWLOntology ontology = state.getOntology();
OWLGenerator axiomGenerator = new OWLGenerator();
Map<String, String> prefixes = ioHelper.getPrefixes();

MappingSet mappingSet = null;
if ( line.hasOption("sssom") ) {
Expand All @@ -158,7 +159,7 @@ public CommandState execute(CommandState state, String[] args) throws Exception
}
if ( line.hasOption("extract") ) {
XrefExtractor extractor = new XrefExtractor();
extractor.setPrefixMap(ioHelper.getPrefixes());
extractor.setPrefixMap(prefixes);
extractor.fillPrefixToPredicateMap(ontology);
if ( mappingSet == null ) {
mappingSet = extractor.extract(ontology);
Expand All @@ -175,14 +176,14 @@ public CommandState execute(CommandState state, String[] args) throws Exception
}

if ( line.hasOption("only-subject-in") ) {
String pr = ioHelper.getPrefixes().get(line.getOptionValue("only-subject-in"));
String pr = prefixes.get(line.getOptionValue("only-subject-in"));
if ( pr != null ) {
axiomGenerator.addStopingRule((mapping) -> !mapping.getSubjectId().startsWith(pr));
}
}

if ( line.hasOption("only-object-in") ) {
String pr = ioHelper.getPrefixes().get(line.getOptionValue("only-object-in"));
String pr = prefixes.get(line.getOptionValue("only-object-in"));
if ( pr != null ) {
axiomGenerator.addStopingRule((mapping) -> !mapping.getObjectId().startsWith(pr));
}
Expand All @@ -209,9 +210,8 @@ public CommandState execute(CommandState state, String[] args) throws Exception

if (line.hasOption("hasdbxref")) {
PrefixManager pm = new PrefixManager();
Map<String, String> clMap = ioHelper.getPrefixes();
for ( String prefixName : clMap.keySet() ) {
pm.add(prefixName, clMap.get(prefixName));
for ( String prefixName : prefixes.keySet() ) {
pm.add(prefixName, prefixes.get(prefixName));
}
IMappingTransformer<String> texter = (mapping) -> pm.shortenIdentifier(mapping.getObjectId());
axiomGenerator.addRule(null, null, new AnnotationAxiomGenerator(ontology,
Expand All @@ -223,7 +223,7 @@ public CommandState execute(CommandState state, String[] args) throws Exception
SSSOMTransformReader<OWLAxiom> sssomtReader = new SSSOMTransformReader<OWLAxiom>(sssomApplication,
line.getOptionValue("ruleset"));
if ( !line.hasOption("no-default-prefixes") ) {
sssomtReader.addPrefixMap(ioHelper.getPrefixes());
sssomtReader.addPrefixMap(prefixes);
}
sssomtReader.read();

Expand Down

0 comments on commit b73167c

Please sign in to comment.