fils/oihBook huggingface dataset:
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/expinst/graphs/person.json") as dgraph:
    doc = json.load(dgraph)
frame = {
  "@context": {"@vocab": "https://schema.org/"},
  "@explicit": "true",
  "@type":     "Person",
  "knowsAbout": ""
}
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/id/x",
    "@type": "Person",
    "knowsAbout": [
        {
            "@type": "Text",
            "description": "Invasive species in brackish water"
        },
        {
            "@type": "URL",
            "url": "https://www.wikidata.org/wiki/Q183368"
        },
        {
            "@id": "https://example.org/id/course/x",
            "@type": "Course",
            "description": "In this course ...",
            "url": "URL to the course"
        }
    ]
}
Example: Institution Graph#
Here we have an example of an data graph for type schema.org/Organization.
For the identifier we are using the a GRID, but this could also be something like a ROR.
 1{
 2    "@context": {
 3        "@vocab": "https://schema.org/"
 4    },
 5    "@id": "https://index.example.org/id/org/x",
5    "@id": "https://index.example.org/id/org/x",
 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    "location": {
14        "@type": "Place",
15        "address": "38 avenue de l'Opera, F-75002, Paris, France",
16        "name": "Paris"
17    },
18    "email": "secretariat(at)example.org",
19    "name": "Organization X",
20    "description": "Description of org ...",
21    "telephone": "( 33 1) 42 68 53 00",
22    "url": "https://example.org/",
23    "member": [
24        {
25            "@id": "https://example.org/id/org/1",
26            "@type": "Organization",
27            "name": "Organization A",
28            "description": "Org A is a potential parent organization of Org X"
29        },
30        {
29        },
30        {
31            "@id": "https://orcid.org/0000-0002-2257-9127",
32            "@type": "Person"
33        }
34    ],
35    "identifier": {
36        "@id": "https://grid.ac/institutes/grid.475727.4",
37        "@type": "PropertyValue",
38        "description": "UN Department of Economic and Social Affairs Sustainable Development",
39        "propertyID": "https://registry.identifiers.org/registry/grid",
40        "url": "https://grid.ac/institutes/grid.475727.4"
41    }
42}
On the property membership#
Line 18-29 show the inclusion of a schema.org/member
property.  There are issues to note here both for consumers (aggregators) and
providers (publishers).   The Person type is show connected simply on a type and
id.  This provides the cleanest connection.  If a member is added by type and id, as
in the case of the “Organization A” link, there is the problem of additional triples
being added.  Here, the name and description properties are going to add triples to the
OIH KG.  In so doing, we run the risk or adding potentially un-authoritative information.
The aggregator doesn’t know if triples here are or are not provided by an actor
authoritative for those properties.  This could be addresses with framing or validation
workflows, or ignored.  The prov elements stored could be leveraged to later track
down sources, but don’t provide further information on the issue of authority.
It is recommended that best practice is to attempt to link only on ids (with a type in
all cases) where possible.  If you are connecting with a type, do not provide additional
properties.  In cases where such an id can not be provided, you may wish to fill out
basic properties you can provide with confidence.
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/expinst/graphs/organization.json") as dgraph:
    doc = json.load(dgraph)
context = {
    "@vocab": "https://schema.org/",
}
compacted = jsonld.compact(doc, context)
jbutils.show_graph(compacted)
Details: Indentifier#
For each profile there are a few key elements we need to know about.  One
key element is what the authoritative reference or canonical identifier is for
a resource.
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/expinst/graphs/organization.json") as dgraph:
    doc = json.load(dgraph)
frame = {
  "@context": {"@vocab": "https://schema.org/"},
  "@explicit": "true",
  "@requireAll": "true",
  "@type":     "Organization",
  "identifier": ""
}
context = {
"identifier": ""
}
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://index.example.org/id/org/x",
    "@type": "Organization",
    "identifier": {
        "@id": "https://grid.ac/institutes/grid.475727.4",
        "@type": "PropertyValue",
        "description": "UN Department of Economic and Social Affairs Sustainable Development",
        "propertyID": "https://registry.identifiers.org/registry/grid",
"propertyID": "https://registry.identifiers.org/registry/grid",
        "url": "https://grid.ac/institutes/grid.475727.4"
    }
}
References#
schema:Person
scheme:Organization
Science on Schema Repository
https://oceanexpert.org/
Example page expert
Example page institution
Ocean Expert: reference: Adam Leadbetter
Vessels#
About#
OIH is exploring how we might leverage schema.org to describe research vessels.
Note that schema.org is a very broad vocabulary and as such specific concepts
like research vessel is not well aligned to current types.
In Schema.org the type Vehicle is described as a device that is designed
or used to transport people or cargo over land, water, air, or through space.
We have used this broad scoping to cover research vessels.  We could go on to
connect this type then to a descriptive property in a concept such as
the WikiData entry for Research Vessel, Q391022.
We may also wish to leverage some of the approaches in Keywords and Defined Terms.
Our goal is to use schema.org as a simple upper level vocabulary that allows
us to describe research vessels in a simple manner and then connect to more
detailed information on them.
So the goal here is to show how we can use schema.org as a discovery layer
and then link more directly to detailed institutional metadata records.
This may also leverage the approaches similar to what is shown in
the Publishing Principles resources.
Observing Infrastructure in general represents an interesting challenge.  A
specified infrastructure could be referenced as a ResearchProject within Schema.org,
though other types would be explored.  One could also build off the base Thing class,
parent to all Schema.org types, then leverage the property schema.org/instrument, itself
parent to all Schema.org types, then leverage the property schema.org/instrument, itself
of type Thing.  This approach provides an initial starting point to build out the
approach.
It should be noted that schema.org/Observation also exists but can only
currently be used with the property schema.org/diseaseSpreadStatistics.
However, if seen useful, there is the potential to connect Observation back to a
type of Infrastructure that does not currently exist in Schema.org but could be
proposed.
Addressing the challenge of Observation Infrastructure, and
potentially revisiting the current OIH type Vessel, may involve engagement with
Schema.org itself, something they encourage.
 1{
 2    "@context": {
 3        "@vocab": "https://schema.org/"
 4    },
 5    "@id": "https://example.org/id/X",
 6    "@type": "Vehicle",
 7    "name": "JOIDES Resolution",
 8    "identifier": {
 9        "@id": "https://example.org/id/vessel/X",
10        "@type": "PropertyValue",
11        "propertyID": "https://en.wikipedia.org/wiki/IMO_number",
12        "url": "https://example.org/id/vessel/X",
13        "description": "Vessel ID "
14    },
13        "description": "Vessel ID "
14    },
15    "countryOfLastProcessing": "Angola",
16    "countryOfOrigin": {
17        "@type": "Country",
18        "name": "Fiji"
19    },
20    "additionalProperty": {
21        "@id": "ID_value_string",
22        "@type": "PropertyValue",
23        "propertyID": "https://en.wikipedia.org/wiki/IMO_number",
24        "url": "https://foo.org/linkToPropertyIDPage",
25        "description": "Any additional properties for the vessel"
26    },
27    "subjectOf": {
28        "@type": "DataDownload",
29        "name": "external-metadata.xml",
30        "description": "Metadata describing the vessel",
31        "encodingFormat": [
32            "application/xml",
33            "https://foo.org/ship01"
34        ],
35        "dateModified": "2019-06-12T14:44:15Z"
36    }
37}
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
sys.path.insert(0, parentdir)
from lib import jbutils
with open("../../../odis-in/dataGraphs/thematics/vessels/graphs/ship.json") as dgraph:
    doc = json.load(dgraph)
context = {
    "@vocab": "https://schema.org/",
}
compacted = jsonld.compact(doc, context)
jbutils.show_graph(compacted)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/tmp/ipykernel_3668912/1146838844.py in <module>
     17 
     18 compacted = jsonld.compact(doc, context)
---> 19 jbutils.show_graph(compacted)
~/src/Projects/OIH/odis-arch/bookRev1/lib/jbutils.py in show_graph(doc, size)
     45         subj = short_name(edge['subject'])
     46         obj = short_name(edge['object'])
---> 47         pred = short_name(edge['predicate'])
     48         if subj and obj and pred:
     49             # Apply different styles to the nodes based on whether they're
~/src/Projects/OIH/odis-arch/bookRev1/lib/jbutils.py in short_name(value, max_length)
     22             # If the URL is too long, hide it
22             # If the URL is too long, hide it
     23             if len(short_url) > max_length:
---> 24                 pieces = split_uri(short_url)
     25                 return join_uri(pieces[0], '...')
     26             else:
NameError: name 'split_uri' is not defined
Details: Indentifier#
For each profile there are a few key elements we need to know about.  One
key element is what the authoritative reference or canonical identifier is for
a resource.
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/vessels/graphs/ship.json") as dgraph:
    doc = json.load(dgraph)
frame = {
  "@context": {"@vocab": "https://schema.org/"},
  "@explicit": "true",
  "@requireAll": "true",
  "@type":     "Vehicle",
"@requireAll": "true",
  "@type":     "Vehicle",
  "identifier": ""
}
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/id/X",
    "@type": "Vehicle",
    "identifier": {
        "@id": "https://example.org/id/vessel/X",
        "@type": "PropertyValue",
        "description": "Vessel ID ",
        "propertyID": "https://en.wikipedia.org/wiki/IMO_number",
"propertyID": "https://en.wikipedia.org/wiki/IMO_number",
        "url": "https://example.org/id/vessel/X"
    }
}
Details: subjectOf#
Like SOS, we are recommending the use of subjectOf to link a simple
Schema.org type to a more detailed metadata description record.  This
allows us to use the easy discovery layer in Schema.org but connect to
domain specific metadata records.
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/vessels/graphs/ship.json") as dgraph:
    doc = json.load(dgraph)
frame = {
  "@context": {"@vocab": "https://schema.org/"},
  "@explicit": "true",
  "@requireAll": "true",
  "@type":     "Vehicle",
  "subjectOf": ""
}
context = {
    "@vocab": "https://schema.org/",
}
}
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/id/X",
    "@type": "Vehicle",
    "subjectOf": {
        "@type": "DataDownload",
        "dateModified": "2019-06-12T14:44:15Z",
        "description": "Metadata describing the vessel",
        "encodingFormat": [
            "application/xml",
            "https://foo.org/ship01"
        ],
"application/xml",
            "https://foo.org/ship01"
        ],
        "name": "external-metadata.xml"
    }
}
References#
ICES
POGO
EurOcean
https://vocab.nerc.ac.uk/search_nvs/C17/
SeaDataNet
Marine Facilities Planner
EuroFleets
Identifiers to use include NOCD Code, Call Sign, ICES Shipcode, MMSI Code, IMO Code
Projects#
About#
Project: An enterprise (potentially individual but typically
collaborative), planned to achieve a particular aim. Use properties from
Organization, subOrganization/parentOrganization to indicate project sub-structures.
Research Project#
This is what a basic research project data graph might look like.  We have
the full record below, but this shows some of the basics we would be
looking for.
This type is based on the Schema.org type Project which
has a sub-type of ResearchProject.
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/projects/graphs/proj.json") as dgraph:
    doc = json.load(dgraph)
frame = {
  "@context": {"@vocab": "https://schema.org/"},
  "@explicit": "true",
  "@requireAll": "true",
  "@type":     "ResearchProject",
  "legalName": "",
  "name": "",
"legalName": "",
  "name": "",
  "url": "",
  "description": "",
  "identifier": {} 
}
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/id/resproj/X",
    "@type": [
        "ResearchProject",
        "PropertyValue"
    ],
    "description": "Repo description ... ",
    "identifier": {
        "@id": "https://grid.ac/institutes/grid.475727.4",
"@id": "https://grid.ac/institutes/grid.475727.4",
        "@type": "PropertyValue",
        "description": "UN Department of Economic and Social Affairs Sustainable Development",
        "propertyID": "https://registry.identifiers.org/registry/grid",
        "url": "https://grid.ac/institutes/grid.475727.4"
    },
    "legalName": "Example Data Repository",
    "name": "ExDaRepo",
    "url": [
        "https://dio.org/id/XYZ",
        "https://www.example-data-repository.org"
    ]
}
Details: Identifier#
For each profile there are a few key elements we need to know about.  One
key element is what the authoritative reference or canonical identifier is for
a resource.
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/projects/graphs/proj.json") as dgraph:
doc = json.load(dgraph)
frame = {
  "@context": {"@vocab": "https://schema.org/"},
  "@explicit": "true",
  "@requireAll": "true",
  "@type":     "ResearchProject",
  "identifier": ""
}
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/id/resproj/X",
    "@type": [
        "ResearchProject",
        "PropertyValue"
    ],
    "identifier": {
"ResearchProject",
        "PropertyValue"
    ],
    "identifier": {
        "@id": "https://grid.ac/institutes/grid.475727.4",
        "@type": "PropertyValue",
        "description": "UN Department of Economic and Social Affairs Sustainable Development",
        "propertyID": "https://registry.identifiers.org/registry/grid",
        "url": "https://grid.ac/institutes/grid.475727.4"
    }
}
Full Research Project#
Here is what our full record looks like.  We have added in several
more nodes to cover things like funding source, policy connections,
spatial area served and parent organization.
  1{
  2  "@context": {
  3    "@vocab": "https://schema.org/"
  4  },
  5  "@type": "ResearchProject",
  6  "@id": "https://example.org/id/resproj/X",
  7  "legalName": "Example Data Repository",
  8  "name": "ExDaRepo",
  9  "url": "https://www.example-data-repository.org",
 10  "description": "Repo description ... ",
 11  "logo": {
 12    "@type": "ImageObject",
11  "logo": {
 12    "@type": "ImageObject",
 13    "url": "https://www.example-data-repository.org/logo.jpg"
 14  },
 15  "identifier": {
 16    "@id": "https://grid.ac/institutes/grid.475727.4",
 17    "@type": "PropertyValue",
 18    "description": "UN Department of Economic and Social Affairs Sustainable Development",
 19    "propertyID": "https://registry.identifiers.org/registry/grid",
 20    "url": "https://grid.ac/institutes/grid.475727.4"
 21  },
 22  "contactPoint": {
 23    "@id": "https://www.example-data-repository.org/about-us",
 24    "@type": "ContactPoint",
 25    "name": "Support",
 26    "email": "info@example-data-repository.org",
 27    "url": "https://www.example-data-repository.org/about-us",
 28    "contactType": "customer support"
 29  },
 30  "funder": {
 31    "@type": "FundingAgency",
 32    "@id": "https://dx.doi.org/10.13039/10000001",
33    "name": "National Science Foundation",
 34    "legalName": "National Science Foundation",
 35    "alternateName": "NSF",
 36    "url": "https://www.nsf.gov/",
 37    "identifier": {
 38      "@id": "https://example.org/id/resproj/X",
 39      "@type": "PropertyValue",
 40      "propertyID": "https://registry.identifiers.org/registry/doi",
 41      "value": "DOI value expressed as doi:{doi}",
 42      "url": "https://dio.org/id/XYZ"
 43    }
 44  },
 45  "funding": [
 46    {
 47      "@id": "{odo:hasAward -> odo:osprey_page}",
 48      "@type": "MonetaryGrant",
 49      "url": "http://www.someinstitute.edu",
 50      "name": "{odo:hasAward -> odo:hasAwardNumber}",
 51      "identifier": "{odo:hasAward -> odo:hasAwardNumber}",
 52      "funder": [
 53        {
 54          "@id": "https://dx.doi.org/10.13039/10000001"
 55        },
 56        {
55        },
 56        {
 57          "@type": "FundingAgency",
 58          "name": "Some other org",
 59          "url": "https://example.funder.org/"
 60        }
 61      ]
 62    }
 63  ],
 64  "ethicsPolicy": {
 65    "@type": "CreativeWork",
 66    "@id": "https://example.org/id/XYZ",
 67    "name": "Name or title of the document",
 68    "description": "Description of the creative work ",
 69    "url": "https://www.foo.org/creativework/ethicsPolicy.pdf"
 70  },
 71  "diversityPolicy": {
 72    "@type": "CreativeWork",
 73    "@id": "https://example.org/id/ABC",
 74    "name": "Name or title of the document",
 75    "description": "Description of the creative work",
 76    "url": "https://www.foo.org/creativework/diversityPolicy.pdf"
 77  },
 78  "areaServed": [
 79    {
 80      "@type": "Place",
 81      "geo": {
80      "@type": "Place",
 81      "geo": {
 82        "@type": "GeoCoordinates",
 83        "latitude": 39.3280,
 84        "longitude": 120.1633
 85      },
 86      "description": "Description of the area served"
 87    },
 88    {
 89      "@type": "Text",
 90      "description": "Textual description of area served"
 91    },
 92    {
 93      "@type": "AdministrativeArea",
 94      "geo": {
 95        "@type": "GeoCoordinates",
 96        "latitude": 39.3280,
 97        "longitude": 120.1633
 98      },
 99      "description": "Needs to be subset of Place, Review Place"
100    }
101  ],
102  "parentOrganization": {
103    "@type": "Organization",
104    "@id": "http://www.someinstitute.edu",
105    "legalName": "Some Institute",
106    "name": "SI",
107    "url": "http://www.someinstitute.edu",
108    "address": {
109      "@type": "PostalAddress",
108    "address": {
109      "@type": "PostalAddress",
110      "streetAddress": "234 Main St.",
111      "addressLocality": "Anytown",
112      "addressRegion": "ST",
113      "postalCode": "12345",
114      "addressCountry": "USA"
115    }
116  }
117}
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/projects/graphs/proj.json") as dgraph:
    doc = json.load(dgraph)
context = {
    "@vocab": "https://schema.org/",
}
compacted = jsonld.compact(doc, context)
jbutils.show_graph(compacted)
References#
https://schema.org/Project