Linking to documents and resources#
Leveraging the ability to link between resources can serve many goals. We may wish to demonstrate connections between people and courses they have taken or or organizations they are connected with. We may be wishing to link documents to people or organizations.
This section will review two key thematic profiles and some examples of how to express links from them to other resources. Our goal will be different in various cases. The two profiles are type CreativeWork and type Organization.
In the case of Organization our purpose may be to express alignment to various principles and policies. These might provide people with an understanding of the goals of an organization when they are searching for or assessing them.
In the case of CreativeWork we are looking to express connections to the publisher and provider of the creative work. This is mostly to connect these works with the responsible party associated with them but may also serve to connect to the principles they are associated with.
Organization link options#
In the following section we will look at three different options for expressing links between an organization and resources that describe the policy and principles of the subject organization.
First we will see the full data graph. We have highlighted the sections we we will review here. Namely the subjectOF and publishingPrinciples predicates.
1{
2 "@context": {
3 "@vocab": "https://schema.org/"
4 },
5 "@id": "https://example.org/permanentUrlToThisJsonDoc",
6 "@type": "Organization",
7 "address": {
8 "@type": "PostalAddress",
9 "addressLocality": "Paris, France",
10 "postalCode": "F-75002",
11 "streetAddress": "38 avenue de l'Opera"
12 },
13 "email": "secretariat(at)example.org",
14 "name": "Organization X",
15 "description": "Description of org ...",
16 "telephone": "( 33 1) 42 68 53 00",
17 "member": [
18 {
19 "@type": "Organization",
20 "name": "Organization A",
21 "description": "Org A is a potential parent organization of Org X"
22 }
23 ],
24 "identifier": {
25 "@id": "https://grid.ac/institutes/grid.475727.4",
26 "@type": "PropertyValue",
27 "description": "UN Department of Economic and Social Affairs Sustainable Development",
28 "propertyID": "https://registry.identifiers.org/registry/grid",
29 "url": "https://grid.ac/institutes/grid.475727.4"
30 },
31 "subjectOf": {
32 "@type": "CreativeWork",
33 "@id": "http://purl.unep.org/sdg/SDGIO_00020173",
34 "url": "http://www.ontobee.org/ontology/SDGIO?iri=http://purl.unep.org/sdg/SDGIO_00020173",
35 "name": "UNSD SDG indicator code:C140c01",
36 "description": "Number of countries making progress ... the oceans and their resources"
37 },
38 "publishingPrinciples": [
39 {
40 "@type": "CreativeWork",
41 "@id": "https://sdgs.un.org/goals/goal14",
42 "url": "https://sdgs.un.org/goals/goal14",
43 "name": "Sustainable Development Goal 14",
44 "description": "Conserve and sustainably use the oceans, seas and marine resources for sustainable development"
45 },
46 {
47 "@type": "CreativeWork",
48 "@id": "https://dx.doi.org/10.1038/sdata.2016.18",
49 "url": "https://www.nature.com/articles/sdata201618",
50 "name": "FAIR data principles",
51 "description": "FAIR Principles definition as referenced from: Wilkinson, M. D. et al. The FAIR Guiding Principles for scientific data management and stewardship."
52 }
53 ]
54}
Show code cell source
import json
from pyld import jsonld
import os, sys
currentdir = os.path.dirname(os.path.abspath(''))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from lib import jbutils
with open("../../../odis-in/dataGraphs/thematics/sdg/graphs/org.json") as dgraph:
doc = json.load(dgraph)
context = {
"@vocab": "https://schema.org/",
}
compacted = jsonld.compact(doc, context)
jbutils.show_graph(compacted)
subjectOf#
Lets take a look at subjectOf. In this case we are using subjectOf to express a connection to a UN SDG. This, subjectOf, could also be used to connect documents describing the policy and principles of an organization or additional metadata for a creative work. When we look at subjectOf we can see we are allowed are allowed to use it on any type Thing, but must point to a CreativeWork or Event.
Note
Recall that in the case of OIH types, the type CourseInstance or EducationEvent are both subtype of Event. Given that we can use subjectOf to connect a Thing to these types as well. Also, Course is a subtype of CreativeWork, so we are good there too in the context of the range of subjectOf. Reference thematic type Training
Show code cell source
import json
from rdflib.extras.external_graph_libs import rdflib_to_networkx_multidigraph
from rdflib.extras.external_graph_libs import rdflib_to_networkx_graph
from pyld import jsonld
import graphviz
import os, sys
currentdir = os.path.dirname(os.path.abspath(''))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from lib import jbutils
with open("../../../odis-in/dataGraphs/thematics/sdg/graphs/org.json") as dgraph:
doc = json.load(dgraph)
frame = {
"@context": {"@vocab": "https://schema.org/"},
"@explicit": "true",
"@requireAll": "true",
"@type": "Organization",
"subjectOf": ""
}
context = {
"@vocab": "https://schema.org/",
}
compacted = jsonld.compact(doc, context)
framed = jsonld.frame(compacted, frame)
jd = json.dumps(framed, indent=4)
print(jd)
jbutils.show_graph(framed)
{
"@context": {
"@vocab": "https://schema.org/"
},
"@id": "https://example.org/permanentUrlToThisJsonDoc",
"@type": "Organization",
"subjectOf": {
"@id": "http://purl.unep.org/sdg/SDGIO_00020173",
"@type": "CreativeWork",
"description": "Number of countries making progress ... the oceans and their resources",
"name": "UNSD SDG indicator code:C140c01",
"url": "http://www.ontobee.org/ontology/SDGIO?iri=http://purl.unep.org/sdg/SDGIO_00020173"
}
}
publishingPrinciples#
Values expected to be one of these types
Used on these types
Lets take a look at publishingPrinciples. This can be used to connect CreativeWork, Organization, or Person to either of CreativeWork or URL. So this allows us to link a CreativeWork to a policy or principle statement. This has some very useful use cases where resources can be grouped based on their connection to those principles and policies.
Show code cell source
import json
from rdflib.extras.external_graph_libs import rdflib_to_networkx_multidigraph
from rdflib.extras.external_graph_libs import rdflib_to_networkx_graph
from pyld import jsonld
import graphviz
import os, sys
currentdir = os.path.dirname(os.path.abspath(''))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from lib import jbutils
with open("../../../odis-in/dataGraphs/thematics/sdg/graphs/org.json") as dgraph:
doc = json.load(dgraph)
frame = {
"@context": {"@vocab": "https://schema.org/"},
"@explicit": "true",
"@requireAll": "true",
"@type": "Organization",
"publishingPrinciples": ""
}
context = {
"@vocab": "https://schema.org/",
}
compacted = jsonld.compact(doc, context)
framed = jsonld.frame(compacted, frame)
jd = json.dumps(framed, indent=4)
print(jd)
jbutils.show_graph(framed)
{
"@context": {
"@vocab": "https://schema.org/"
},
"@id": "https://example.org/permanentUrlToThisJsonDoc",
"@type": "Organization",
"publishingPrinciples": [
{
"@id": "https://sdgs.un.org/goals/goal14",
"@type": "CreativeWork",
"description": "Conserve and sustainably use the oceans, seas and marine resources for sustainable development",
"name": "Sustainable Development Goal 14",
"url": "https://sdgs.un.org/goals/goal14"
},
{
"@id": "https://dx.doi.org/10.1038/sdata.2016.18",
"@type": "CreativeWork",
"description": "FAIR Principles definition as referenced from: Wilkinson, M. D. et al. The FAIR Guiding Principles for scientific data management and stewardship.",
"name": "FAIR data principles",
"url": "https://www.nature.com/articles/sdata201618"
}
]
}
Sustainable Development Goals#
The following example provides an an approach to connecting Sustainable Development Goals (SDGs) could be linked to via subjectOf.
Other potential links could be made to things such as the UNDRR-ISC Hazard Definition & Classification
As this is a CreateWork, we can now use one more linking property, the Schema.org citation property. By comparison, the publishingPrinciples or subjectOf connections carry a bit more semantic meaning.
1{
2 "@context": {
3 "@vocab": "https://schema.org/"
4 },
5 "@type": "CreativeWork",
6 "@id": "https://example.org/permanentUrlToThisJsonDoc",
7 "name": "Name or title of the document",
8 "description": "Description of the resource to aid in searching",
9 "distribution": {
10 "@type": "DataDownload",
11 "contentUrl": "https://www.sample-data-repository.org/dataset/472032.tsv",
12 "encodingFormat": "text/tab-separated-values"
13 },
14 "citation": {
15 "@type": "CreativeWork",
16 "@id": "http://purl.unep.org/sdg/SDGIO_00020173",
17 "url": "http://www.ontobee.org/ontology/SDGIO?iri=http://purl.unep.org/sdg/SDGIO_00020173",
18 "name": "UNSD SDG indicator code:C140c01",
19 "description": "Number of countries making progress ... the oceans and their resources"
20 },
21 "maintainer" : {
22 "@type" : "Organization",
23 "@id": "https://ror.org/050bms902",
24 "description": "UN Department of Economic and Social Affairs Sustainable Development"
25 }
26}
Show code cell source
import json
from pyld import jsonld
import os, sys
currentdir = os.path.dirname(os.path.abspath(''))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from lib import jbutils
with open("../../../odis-in/dataGraphs/thematics/sdg/graphs/doc.json") as dgraph:
doc = json.load(dgraph)
context = {
"@vocab": "https://schema.org/",
}
compacted = jsonld.compact(doc, context)
jbutils.show_graph(compacted)
citation#
Schema.org citation provides a way to link to another creative work. This property can be pointed to either Text or CreativeWork. It should also be noted that citation can only be used on type CreativeWork.
Due to the limit to use on CreateWork only, this example is not seen in the above examplewhich is of type Organization.
The actual semantics of citation is rather vague stating it is a method to cite or reference another creative work.
Show code cell source
import json
from rdflib.extras.external_graph_libs import rdflib_to_networkx_multidigraph
from rdflib.extras.external_graph_libs import rdflib_to_networkx_graph
from pyld import jsonld
import graphviz
import os, sys
currentdir = os.path.dirname(os.path.abspath(''))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from lib import jbutils
with open("../../../odis-in/dataGraphs/thematics/sdg/graphs/doc.json") as dgraph:
doc = json.load(dgraph)
frame = {
"@context": {"@vocab": "https://schema.org/"},
"@explicit": "true",
"@requireAll": "true",
"@type": "CreativeWork",
"citation": ""
}
context = {
"@vocab": "https://schema.org/",
}
compacted = jsonld.compact(doc, context)
framed = jsonld.frame(compacted, frame)
jd = json.dumps(framed, indent=4)
print(jd)
jbutils.show_graph(framed)
{
"@context": {
"@vocab": "https://schema.org/"
},
"@id": "https://example.org/permanentUrlToThisJsonDoc",
"@type": "CreativeWork",
"citation": {
"@id": "http://purl.unep.org/sdg/SDGIO_00020173",
"@type": "CreativeWork",
"description": "Number of countries making progress ... the oceans and their resources",
"name": "UNSD SDG indicator code:C140c01",
"url": "http://www.ontobee.org/ontology/SDGIO?iri=http://purl.unep.org/sdg/SDGIO_00020173"
}
}