Skip to content

ibm-hyperknowledge/rdf2hk

Repository files navigation

rdf2hk

This library contains classes and functions to convert RDF model to the Hyperknowledge model

Install

npm install rdf2hk

Usage

const RDF2HK = require("rdf2hk");

RDF to Hyperknowledge

Example:

const GraphFactory = RDF2HK.GraphFactory;

const mimeType = "application/turtle" // application/json | application/n-triples | application/n-quads | application/trig | application/turtle | application/rdf+xml
GraphFactory.parseGraph(inputData, mimeType, (err, graph) =>
{
	if(err)
	{
		console.error(err);
		return;
	}

	let hkentities = RDF2HK.Parser.parseGraph(graph);

	console.log(hkentities); // print the converted entities

	// <...>
}); 

Hyperknowledge to RDF

Example:

const GraphFactory = RDF2HK.GraphFactory;

const mimeType = "application/turtle" // application/json | application/n-triples | application/n-quads | application/trig | application/turtle | application/rdf+xml

let graph = GraphFactory.createGraph(mimeType);
    
Serializer.serialize(hkentities, {}, graph); // options: see api reference

GraphFactory.serializeGraph(graph, (err, data) =>
{
	if(!err)
	{
		// Print the rdf serialized data
		console.log(data);

		// <...>
	}
	else
	{
		console.error(err);
	}

});

About

Functionalities to promote conversions between RDF and Hyperknowledge

Resources

License

Stars

Watchers

Forks

Packages

No packages published