Neutralize Pesky Miscreants

    @openhps/rdf
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.31 • Public • Published

    OpenHPS
    @openhps/rdf

    Build Status Maintainability npm version

    @openhps/coreAPI


    This OpenHPS module adds RDF data support to the OpenHPS framework. The main vocabulary used for serializing data is the POsitioning System Ontology (POSO) ontology that will be presented at ISWC 2022.

    Getting Started

    If you have npm installed, start using @openhps/rdf with the following command.

    npm install @openhps/rdf --save

    Usage

    RDFSerializer

    The RDFSerializer is a similar utility as the DataSerializer from @openhps/core. Instead of serializing and deserializing to JSON, it converts to RDF triples.

    to thing

    Serialize a serializable object to an RDF thing.

    import { RDFSerializer, Thing } from '@openhps/rdf';
    
    const thing: Thing = RDFSerializer.serialize(new DataObject(/* ... */));

    When storing a named object, a base URI should be provided.

    to quads

    Serialize a serializable object to RdfJS Quads.

    import { RDFSerializer } from '@openhps/rdf';
    import { Quad } from 'rdfjs';
    
    const quads: Quad[] = RDFSerializer.serializeToQuads(new DataObject(/* ... */));

    When storing a named object, a base URI should be provided.

    to string

    Serializing to a string is possible. We use N3 for exporting the serializable objects to turtle, Notation-3 or other supported formats.

    import { RDFSerializer } from '@openhps/rdf';
    
    const turtle: string = RDFSerializer.stringify(new DataObject(/* ... */), {
        format: 'text/turtle',
        prettyPrint: true
    });

    from thing

    Deserialize a serializable object from a thing.

    import { RDFSerializer, Thing } from '@openhps/rdf';
    
    const thing: Thing
    
    /* ... */
    
    const object: DataObject = RDFSerializer.deserialize(thing);

    Create a new RDF serializable object

    SerializableObject

    import '@openhps/rdf'; // Import to load type declarations
    import { SerializableObject, SerializableMember } from '@openhps/core';
    
    @SerializableObject({
        rdf: {
            type: 'http://myontology.org#SomeObject'
        }
    })
    class SomeObject {
    
    }

    SerializableMember

    API documentation for literal: https://openhps.org/docs/rdf/interfaces/rdfliteraloptions

    import { SerializableMember, SerializableObject } from "@openhps/core";
    import { foaf } from "@openhps/rdf";
    
    @SerializableObject({
        rdf: {
            type: foaf.Project
        }
    })
    export class Project {
        @SerializableMember({
            rdf: {
                predicate: foaf.name
            }
        })
        name: string;
    }

    SPARQLDataDriver

    The SPARQL endpoint uses Comunica as its query engine while still using the query syntax from MongoDB.

    Contributors

    The framework is open source and is mainly developed by PhD Student Maxim Van de Wynckel as part of his research towards Hybrid Positioning and Implicit Human-Computer Interaction under the supervision of Prof. Dr. Beat Signer.

    Contributing

    Use of OpenHPS, contributions and feedback is highly appreciated. Please read our contributing guidelines for more information.

    License

    Copyright (C) 2019-2022 Maxim Van de Wynckel & Vrije Universiteit Brussel

    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

    Install

    npm i @openhps/rdf

    DownloadsWeekly Downloads

    2

    Version

    0.1.31

    License

    Apache-2.0

    Unpacked Size

    201 MB

    Total Files

    600

    Last publish

    Collaborators

    • maximvdw