-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
e745e2a
commit dbbaefe
Showing
7 changed files
with
333 additions
and
91 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from rdflib.term import Node | ||
|
||
|
||
def reformat_onto_iri(iri: Node) -> str: | ||
"""Takes a rdflib Node and returns a prefixed IRI in string form.""" | ||
iri_str = str(iri) | ||
if "http://www.w3.org/2000/01/rdf-schema#" in iri_str: | ||
return f'rdfs:{iri_str.split("#")[-1]}' | ||
onto = iri_str.split("/")[-2] | ||
ending = iri_str.split("#")[-1] | ||
if onto == "knora-api": | ||
return ending | ||
return f"{onto}:{ending}" | ||
|
||
|
||
def reformat_data_iri(iri: Node) -> str: | ||
"""Takes a rdflib Node with in the data namespace and returns only the suffix.""" | ||
return str(iri).replace("http://data/", "") |
This file contains 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
Oops, something went wrong.