Created
December 12, 2025 15:01
-
-
Save epoz/32962ad6ace6d11e9470566955f492ca to your computer and use it in GitHub Desktop.
Nicer prefixes for OBO style properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import httpx, rdflib | |
| nfdicore = httpx.get('https://github.com/ISE-FIZKarlsruhe/nfdicore/raw/refs/heads/main/nfdicore-full.ttl', follow_redirects=True) | |
| g = rdflib.Graph() | |
| g.parse(data=nfdicore.text, format='turtle') | |
| nfdi4c = httpx.get('https://raw.githubusercontent.com/ISE-FIZKarlsruhe/nfdi4culture/refs/heads/main/cto-full.ttl', follow_redirects=True) | |
| g.parse(data=nfdi4c.text, format='turtle') | |
| labels = sorted([(s, oo) for s,p,o in g.triples((None, rdflib.RDF.type, None)) for ss, pp, oo in g.triples( (s, rdflib.RDFS.label, None) ) if o in (rdflib.OWL.DatatypeProperty, rdflib.OWL.ObjectProperty) and oo.language == 'en' and not str(s).startswith('https://schema.org/')]) | |
| prefixes = '\n'.join([f"@prefix {label.replace(' ', '_')}: <{iri}> ." for iri, label in labels]) | |
| print(prefixes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment