@universis/skos
v1.7.0
Published
A common data model for sharing and linking knowledge organization systems
Maintainers
Readme
@universis/skos
Universis Project module for working with SKOS vocabularies.
@universis/skos#SchemaLoader exports Concept and ConceptScheme` classes for representing SKOS concepts and concept schemes.
Installation
npm install @universis/skosUsage
Include schema loader under application configuration settings.schema.loaders section:
{
"settings": {
"schema": {
"loaders": [
{
"loaderType": "@universis/skos#SchemaLoader"
}
]
}
}
}Then you can start using SKOS concepts and concept schemes in your application.
import { DataContext } from '@themost/data';
async function getEventStatusTypes(context: DataContext): Promise<{ about: string; identifier: string; lang: string; prefLabel: string }[]> {
return context.model('Concept')
.where('inScheme/about')
.equal('http://publications.europa.eu/resource/authority/event-status')
.and('prefLabel/lang').equal('en')
.select('about',
'identifier',
'prefLabel/lang as lang',
'prefLabel/value as prefLabel'
);
}
This example retrieves SKOS concepts from the EU Publications event status authority. The result will include the concept's URI, identifier, preferred label language, and preferred label value.
[
{
"about": "http://publications.europa.eu/resource/authority/event-status/CANCELLED",
"identifier": "CANCELLED",
"lang": "en",
"prefLabel": "Event was cancelled"
},
{
"about": "http://publications.europa.eu/resource/authority/event-status/DEADLINE",
"identifier": "DEADLINE",
"lang": "en",
"prefLabel": "Event is a deadline for another event"
},
{
"about": "http://publications.europa.eu/resource/authority/event-status/NORMAL",
"identifier": "NORMAL",
"lang": "en",
"prefLabel": "Event has occurred in the past"
},
{
"about": "http://publications.europa.eu/resource/authority/event-status/OP_DATPRO",
"identifier": "OP_DATPRO",
"lang": "en",
"prefLabel": "Provisional data"
},
{
"about": "http://publications.europa.eu/resource/authority/event-status/PROJECTED",
"identifier": "PROJECTED",
"lang": "en",
"prefLabel": "Event is planned to happen in the future"
}
]@universis/skos#VocabularyService provides methods for working with SKOS vocabularies, such as retrieving concepts by their URIs or identifiers.
import {VocabularyService} from '@universis/skos';
import {DataContext} from '@themost/data';
import {application} from 'express';
async function importEventStatusTypes(context): Promise<void> {
const application = context.getConfiguration().getApplication();
const vocabularyService = new VocabularyService(application);
await vocabularyService.importFrom(context, 'http://publications.europa.eu/resource/distribution/event-status/20230614-0/rdf/skos_core/event-status-skos.rdf');
}@universis/skos provides a command-line interface for importing concept schemes using a web resource
npx @universis/skos --config ./dist/server/config/app.production.json "http://publications.europa.eu/resource/distribution/event-status/20230614-0/rdf/skos_core/event-status-skos.rdf"where --config parameter defines the path of the target application configuration file. The operation will try to extract concept schemes and concepts included in the specified resource
and import them into the default data storage defined by the given application configuration.
