Skip to content

Commit

Permalink
Add the '--only-(subject|object)-in' options.
Browse files Browse the repository at this point in the history
Add an option to filter mappings according to their subject ID:
'--only-subject-in PFX' will filter out any mapping whose subject ID
does not start with the specified prefix.

Likewise, the '--only-object-in PFX' option will filter out any mapping
whose object ID does not start the specified prefix.
  • Loading branch information
gouttegd committed Sep 3, 2023
1 parent 802f8af commit 5a7bb89
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
20 changes: 18 additions & 2 deletions core/src/site/apt/robot-sssom-inject.apt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,24 @@ ROBOT sssom-inject command
ontology with the generated axioms. The newly created ontology becomes
ROBOT’s current ontology, and will passed down the command pipeline.

Use the option <<<--invert>>> to invert the entire mapping set before
generating any axioms out of it.
* Mapping preprocessing

A few options allow for basic preprocessing of a mapping set. They are
intended to avoid having to use SSSOM/Transform rules for simple use
cases.

The <<<--invert>>> option allows to invert the entire mapping set.

The <<<--only-subject-in>>> allows to filter the mapping set to only
keep mappings whose subject ID starts with the specified prefix. For
example, use <<<---only-subject-in CL>>> to only keep (and process)
mappings with a subject in CL.

The <<<--only-object-in>>> is similar, but for the object side of
mappings.

These options are applied before any other processing. Inversion, if
specified, is always performed first.

* Checking for the existence of the subject and/or object

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public SSSOMInjectionCommand() {
"write generated axioms to several output ontologies according to dispatch table");
options.addOption("r", "reasoner", true, "reasoner to use");
options.addOption(null, "invert", false, "invert the mapping set prior to any processing");
options.addOption(null, "only-subject-in", true, "Only process mappings whose subject has the given prefix");
options.addOption(null, "only-object-in", true, "Only process mappings whose object has the given prefix");
}

@Override
Expand Down Expand Up @@ -172,6 +174,20 @@ public CommandState execute(CommandState state, String[] args) throws Exception
axiomGenerator.addRule(null, (mapping) -> CommonPredicate.invert(mapping), null);
}

if ( line.hasOption("only-subject-in") ) {
String pr = ioHelper.getPrefixes().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"));
if ( pr != null ) {
axiomGenerator.addStopingRule((mapping) -> !mapping.getObjectId().startsWith(pr));
}
}

if ( line.hasOption("check-subject") ) {
axiomGenerator.setCheckSubjectExistence(ontology);
}
Expand Down

0 comments on commit 5a7bb89

Please sign in to comment.