I need to describe the capability of devices and how to invoke the capabilities functions semantically. In order to achieve that I created a super simple RDF Graph and used @rdfjs/serializer-jsonld library to serialize the graph to JSON-LD file with the following code:
const rdf = require('@rdfjs/data-model')
const Readable = require('stream').Readable
const SerializerJsonld = require('@rdfjs/serializer-jsonld')
const serializerJsonld = new SerializerJsonld()
const input = new Readable({
objectMode: true,
read: () => {
input.push(rdf.quad(
rdf.literal('Device001'),
rdf.namedNode('https://schema.org/potentialAction'),
rdf.namedNode('https://schema.org/PhotographAction')))
input.push(rdf.quad(
rdf.namedNode('https://schema.org/PhotographAction'),
rdf.namedNode('https://w3id.org/function/ontology#Function'),
rdf.literal('takePhoto')))
input.push(null)
}
})
const output = serializerJsonld.import(input)
output.on('data', jsonld => {
console.log(jsonld)
})
which creates the following JSON-LD file.
[
{
"@id": "Device001",
"https://schema.org/potentialAction": {
"@id": "https://schema.org/PhotographAction"
}
},
{
"@id": "https://schema.org/PhotographAction",
"https://w3id.org/function/ontology#Function": "takePhoto"
}
]
Is this semantically correct? Is is okay to combine [schema.org] ontology (https://schema.org/) and function ontology without using RDF Schema or any class or type? Is there a better way to combine 2 ontologies? JSON-LD playground gives no errors but is there a better way to validate?
Here you are creating a class-less instance identified by the URI
https://schema.org/PhotographAction, but you probably want to create an instance that has the classhttps://schema.org/PhotographAction, and that is identified by an URI under your control.Here you are saying something about the class
https://schema.org/PhotographAction, but you probably want to say something about your instance that has this class (where the instance is identified by the URI you provided in the first node).I’m not familiar with the Function Ontology, but as
https://w3id.org/function/ontology#Functionis a class, your probably don’t want to use it as property.