Using ontologies in Javascript apps
Ontologies are resources that describe concepts and how several classes and properties in a certain domain relate to each other. For example, if you're creating a social network app, you might want to use the Friend of a Friend (FOAF) ontology, which describes things like "Person" and "knows". When creating linked data applications, you're likely to work a lot with ontologies. Since ontologies, their classes and their properties all use URLs as identifiers, that means that you might write a lot of long strings. This is not only bothersome, but also a source of unnecessary typos and a possible performance bottleneck.
That's why we created the @ontologies project. This is an open source repository that converts RDF ontologies into JS exports, pubslihed in NPM for easy re-use. If your IDE is smart enough, it will auto-import the ontologies and provide and useful tooltips with ontological descriptions for each item.
How to use it
## Add it to your project
yarn add @ontologies/core @ontologies/schema
// Initialize it once (./init.js)
import { setup } from "@ontologies/core";
setup();
// Use it
import "./init";
import { name } from "@ontologies/schema";
document.getElementById("app").innerHTML = `
<h1>Schema URL: ${name.value}</h1>
`;
Check out a running example on CodeSandbox.
We've currently added ActivityStreams, DCElements, DCTerms, DCMIType, FOAF, OWL, PROV-O, RDF, RDFS, Schema, SHACL, SKOS and XSD.
PRs for new ontologies are welcome!