Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't get the prefix option to work. #457

Closed
marijane opened this issue Apr 1, 2019 · 7 comments
Closed

I can't get the prefix option to work. #457

marijane opened this issue Apr 1, 2019 · 7 comments

Comments

@marijane
Copy link

marijane commented Apr 1, 2019

I'm trying to convert a set of triples in .nq format to .ttl:

robot convert -p "schema: http://schema.org" -p "ohsu: http://purl.org/ohsu/schema#" -i pharmacies-201810.nq -f ttl -o pharmacies-201903.ttl

This is what I get in the output file:

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.w3.org/2002/07/owl#> .

I've also had this problem in the past, with the merge command.

Is this a bug or am I using the prefix option incorrectly?

@beckyjackson
Copy link
Contributor

Hi @marijane, thanks for reaching out! The --prefix option is used to read prefixes from input files (such as lists of terms for extraction), but does not change what is written to the output file. Turtle format will only write those default prefixes.

@cmungall
Copy link
Contributor

cmungall commented Apr 1, 2019

It is possible to get the OWLAPI to use specified prefixes in output, this is how owltools does it:

https://github.com/owlcollab/owltools/blob/5a8a91997ae7302001866ff5efbcd2aec4c5b70b/OWLTools-Runner/src/main/java/owltools/cli/CommandRunner.java#L3699-L3702

It is nice to have preferred prefixes used in ttl etc, maybe add as an option to convert?

@beckyjackson
Copy link
Contributor

@jamesaoverton @cmungall I implemented one approach for this using the --add-prefix (-A) option that we use in Rename to support backwards compatibility (i.e., the --prefix option does not add anything to the output). Please let me know if you had something else in mind.


The --add-prefix option allows you to specify a prefix mapping in the same way as --prefix:

robot --noprefixes --add-prefix "foo: http://foo#" \
  export-prefixes --output results/foo.json

The difference is that the --prefix option does not include the new prefix in the header of the output ontology, whereas --add-prefix does, for example in Turtle:

@prefix foo: <http://foo#> .

@jamesaoverton
Copy link
Member

Combined with an --add-prefixes option, this would solve the immediate issue.

Are we already using the -A short option in some other command?

It feels sub-optimal, but this is better than any other idea I've come up with.

@beckyjackson
Copy link
Contributor

template --include-annotations is also -A so that wouldn't work. I thought I looked before, but I missed that originally. We could make the short option -ap for --add-prefix and -AP for --add-prefixes.

We need to still support rename -A so I'll keep that there?

@jamesaoverton
Copy link
Member

I'm pretty sure that Apache Commons CLI only allows short options to be a single character:

https://commons.apache.org/proper/commons-cli/apidocs/org/apache/commons/cli/Options.html#addOption(java.lang.String,java.lang.String,boolean,java.lang.String)

Not having a short option in this case is fine. We need to keep rename -A, which will be a little weird.

@jamesaoverton
Copy link
Member

This should be fixed by #488 and available in the next ROBOT release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants