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

'remove' based on language attributes #571

Closed
allysonlister opened this issue Sep 25, 2019 · 6 comments
Closed

'remove' based on language attributes #571

allysonlister opened this issue Sep 25, 2019 · 6 comments
Assignees

Comments

@allysonlister
Copy link

allysonlister commented Sep 25, 2019

I would like to remove all rdfs:labels that have anything other than "anystring"@en, also preserving those rdfs:labels that have no language attribute set.

To try to get this started, I attempted to just remove those labels that have "anything"@zh as follows (a good test ontology for this is CLO at http://www.clo-ontology.org/ as it has multiple languages):

java -jar build/robot.jar  remove --input input.owl --term rdfs:label --select "rdfs:label=~'.*'@zh"  --output build/test.owl

However the above statement removes all labels whether or not they have a language set. I can't help feeling that I'm circling around the appropriate command, but I just can't see it. Please could I have some pointers?

Thanks :) Allyson

@jamesaoverton
Copy link
Member

Hmm. It looks like we don't support selection by language tags in remove/filter. We do support selection with datatypes (^^), so that's an oversight that we should fix. @beckyjackson Can you please add this?

The =~ matching rule you're trying to use will only match the content of an annotation. The language information is stored separately, so that won't do what you want.

My best suggestion with current ROBOT features is to use SPARQL UPDATE:

java -jar build/robot.jar query --input input.owl --update delete-en.ru  --output build/test.owl

where delete-en.ru is a file with this content:

DELETE { ?s ?p ?o }
WHERE { ?s ?p ?o; FILTER(lang(?o) = "en") }

That should work, but I haven't tested it. More documentation here: http://robot.obolibrary.org/query#sparql-update

@allysonlister
Copy link
Author

Thanks very much. Will keep an eye out on the remove/filter command. In the meantime, your sparql update suggestion worked perfectly. For reference, here is the .ru file I used in the end:

# Delete any rdfs:label where the language is set to 'zh'
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

DELETE {
  ?class rdfs:label ?display_name
}
WHERE {
  ?class rdf:type owl:Class.
  ?class rdfs:label ?display_name
  FILTER(lang(?display_name) = "zh")
}

@beckyjackson
Copy link
Contributor

New selectors added by #574:
CURIE=^^datatype, e.g. rdfs:label=^^xsd:string
CURIE=@language, e.g. rdfs:label=@en
More details here

This doesn't quite cover this use case, but I think SPARQL UPDATE is still the right method to do this. That said, these new selectors allow you to select terms based on their annotations, so you could remove the labels on any terms that have a given language tag:

robot remove --input test.owl  \
  --select "rdfs:label=@en" \
  --include-term rdfs:label \
  --axioms annotation  \
  --trim false \
  --output test-2.owl

Note that this will remove all labels on any term that has an @en language tag, though.

@allysonlister - did the SPARQL UPDATE work out for you? Is this issue OK to close? Thank you!

@allysonlister
Copy link
Author

Thanks very much! And yes, the SPARQL UPDATE worked great for me - I included the code above for reference. I'm happy for you to close the ticket - just didn't want to do it myself in case you were waiting for something internally first.

Thanks again for all your help :) Allyson

@beckyjackson
Copy link
Contributor

Great, thank you!

@matentzn
Copy link
Contributor

Just came across the same, wanting to remove all labels (all annotations for that matter) that were Chinese. Using sparql as well, thanks all.

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