Git Product home page Git Product logo

hylar-reasoner's Introduction

HyLAR-Reasoner HyLAR icon

A rule-based incremental reasoner for the Web.

To cite HyLAR: HyLAR+: improving Hybrid Location-Agnostic Reasoning with Incremental Rule-based Update

Table of contents

Description

HyLAR is a Hybrid Location-Agnostic incremental Reasoner that uses known rdf-based librairies such as rdfstore.js, sparqljs and rdf-ext while providing an additional incremental reasoning engine. HyLAR can be either used locally as a npm module or globally as a server, and comes with a browserified version.

HyLAR relies on the rdfstore.js triplestore and therefore supports JSON-LD, N3 and Turtle serializations. SPARQL support is detailed here. The inferences initially supported by HyLAR are described at the bottom of this page. HyLAR supports custom business rules.

Use HyLAR locally

Installation

To use HyLAR locally, just launch npm install --save hylar

Loading an ontology

Import HyLAR, then classify your ontology and query it using load(), which takes three parameters:

  • rawOntology: A string, the raw ontology.
  • mimeType: A string, either text/turtle, text/n3 or application/ld+json.
  • keepOldValues: A boolean: true to keep old values while classfying, false to overwrite the KB. Default is false.
const Hylar = require('hylar');
const h = new Hylar();
    
// async function
h.load(rawOntology, mimeType, keepOldValues);

Querying an ontology

Once loaded, HyLAR is able to process SPARQL queries using query(), with the following parameters:

  • query: A string, the SPARQL query
let results = await h.query(query);

Create your own rules

HyLAR supports insertion of custom forward-chaining conjunctive rules in the form:

triple_head_1 ^ ... ^ triple_head_n -> triple_body_3

Where triple_head_x and triple_body_x are respectively "cause" triples (i.e. the input) and "consequence" triples (i.e. the inferred output) in the form:

(subject predicate object)

Each subject/predicate/object can be one of the following:

  • A variable, e.g. ?x
  • An URI, e.g. http://www.w3.org/2000/01/rdf-schema#subClassOf
  • A literal, e.g. "0.5", "Hello world!"

A predicate can also be any of these comparison operators: <, >, =, <=, =>.

Rule add example (first param: the 'raw' rule, second param: the rule name)

h.parseAndAddRule('(?p1 http://www.w3.org/2002/07/owl#inverseOf ?p2) ^ (?x ?p1 ?y) -> (?y ?p2 ?x)', 'inverse-1');

Rule removal example (first and only param: either the rule name or the raw rule)

h.removeRule('inverse-1');
// Outputs "[HyLAR] Removed rule (?p1 inverseOf ?p2) ^ (?x ?p1 ?y) -> (?y ?p2 ?x)" if succeeded.

Use HyLAR in a browser

Run npm run clientize, which will generate the file hylar-client.js. Include this script in your page with this line:

<script src="path-to/hylar-client.js"></script>

As in the node module version, you can instantiate HyLAR with const h = new Hylar(); and call the same methods query(), load() and parseAndAddRule().

Use HyLAR as a server

Installation

npm install -g hylar

Run the server

Command hylar with the following optional parameters

  • --port <port_number> (port 3000 by default)
  • --no-persist deactivates database persistence (activated by default)
  • --graph-directory </your/base/graph/directory/> where local datasets are saved
  • --entailment either OWL2RL (default) or RDFS
  • --reasoning-method either incremental (default) or tag-based (provides reasoning proofs)

Hylar server API

  • /classify/{FILE_NAME} (GET)

Loads, parses and classify the file {FILE_NAME} from the ontology directory.

Note: You don't have to specify the ontology file's mimetype as it is detected automatically using its extension.

  • /classify/ (GET)

Allows classifying an ontology as a string, which requires its original serialization type.

Body parameters filename the absolute path of the ontology file to be processed. mimetype the serialization of the ontology (mimetype, one of text/turtle, text/n3 or application/ld+json).

  • /query(GET)

SPARQL queries your loaded ontology as does Hylar.query().

Body parameters query the SPARQL query string.

  • /rule (PUT)

Puts an list of custom rules and adds it to the reasoner.

Body parameters rules the array of conjunctive rules.

Supported inferences

HyLAR supports a subset of OWL 2 RL and RDFS.

  • RDFS
    • Rules: rdf1, rdfs2, rdfs3, rdfs4a, rdfs4b, rdfs5, dfs6, rdfs7, rdfs8, rdfs9, rdfs10, rdfs11, rdfs12, rdfs13.
    • Supports all RDFS axiomatic triples, except axioms related to rdf:Seq and rdf:Bag.
  • OWL 2 RL
    • Rules: prp-dom, prp-rng, prp-fp, prp-ifp, prp-irp, prp-symp, prp-asyp, prp-trp, prp-spo1, prp-spo2, prp-eqp1, prp-eqp2, prp-pdw, prp-inv1, prp-inv2, prp-npa1, prp-npa2, cls-nothing2, cls-com, cls-svf1, cls-svf2, cls-avf, cls-hv1, cls-hv2, cls-maxc1, cls-maxc2, cls-maxqc1, cls-maxqc2, cls-maxqc3, cls-maxqc4, cax-sco, cax-eqc1, cax-eqc2, cax-dw, scm-cls, scm-sco, scm-eqc1, scm-eqc2, scm-op, scm-dp, scm-spo, scm-eqp1, scm-eqp2, scm-dom1, scm-dom2, scm-rng1, scm-rng2, scm-hv, scm-svf1, scm-svf2, scm-avf1, scm-avf2
    • Axiomatic triples are not yet supported.

Publications

Location-agnostic mechanism

Terdjimi, M., Médini, L., & Mrissa, M. (2015, May). Hylar: Hybrid location-agnostic reasoning 📚 In ESWC Developers Workshop 2015 (p. 1).

Incremental reasoning on the Web with HyLAR

Terdjimi, M., Médini, L., & Mrissa, M. (2016, April). HyLAR+: improving hybrid location-agnostic reasoning with incremental rule-based update 📚 In Proceedings of the 25th International Conference Companion on World Wide Web (pp. 259-262). International World Wide Web Conferences Steering Committee.

Tag-based maintenance

Terdjimi, M., Médini, L., & Mrissa, M. (2018, April). Web Reasoning Using Fact Tagging 📚 In Companion of the The Web Conference 2018 on The Web Conference 2018 (pp. 1587-1594). International World Wide Web Conferences Steering Committee.

hylar-reasoner's People

Contributors

lmedini avatar madsholten avatar mterdjimi avatar pdehaan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hylar-reasoner's Issues

Impossible to load a JSON-LD that contains the ```@language``` keyword

Hey,
It seems that it's impossible to load a JSON-LD that contains the @language keyword.
For example: '@language': 'en-us' causes an { SyntaxError: Expected [1] QueryUnit or [29] UpdateUnit but "I" found. error.
rdfstore/src/parser.js:2760:14 Seems to be the cause.

Here you will find a minimal working example: https://github.com/StatelessCat/mwe-hylar/blob/292112453f04d6c32be93b5bc5887c3b9afb3917/mwe-hylar.js#L13 .

I'll check if I can reproduce the bug on rdfstore directly.

Thanks in advance for your help.
Raphaël .

Hylar as a dependency of a strict-Node.js 13 application

Hi,
When adding [email protected] as a dependency for a project that requires Node.js 13 to run, I did not succeed in building its dependencies, using npm nor yarn.

The faulty "sqlite3" transitive dependency of your project ([email protected] -> [email protected] -> [email protected] -> [email protected]) prevent it.

The workaround is obviously to install Hylar as Node.js 10, then to require it in Node.js 13, which works, but not optimal. Or just to expressly --ignore-engines and runtimes checks in npm but it did not work for me (still a problem to build sqlite3).

What is your opinion on it?
Is it possible to change multer as an optional dependency?
What I'm missing on this problem?

Thanks.

Accessing RDFStore event API from Hylar

First thank you very much for this amazing work. I have a somewhat silly question : since Hylar uses RDFStore, would it be possible to "simply" uses RDFStore Event API in order to detect specific change in the graph? My use case would be to trigger a callback function whenever there is a change associated to an instance i of a given concept C. I'm not sure how to access the RDFStore object from the Hylar object though.

Thank you in advance and regards!

Updates to core components [feature]

Thanks for making this tool; it is very useful.

I just wanted to let you know that I have extracted the core logic, removed most dependencies, and converted the core components of the library to typescript (including updates to slightly more modern syntax using lebab) here. This is because I am using the package in some of my own frontend tooling.

Let me know if you would like me to create a PR with any of these changes.

Console error messages overrided by HyLAR

Hi !

I use HyLAR in a browser version, and it appears that HyLAR catch and then overrides the error messages thrown by my application such as :
[HyLAR] ERROR : An error

The incriminated function is located line 2646 in hylar-client.js.
Is this behavior intentional?

Regards

EDIT:
It also seems to be the case for warnings.

CONSTRUCT result duplicates shows [object Object][object Object][object Object]

what is duplicates used for ?

I20200519-15:39:59.451(8)? {
I20200519-15:39:59.451(8)?   "triples": [
I20200519-15:39:59.451(8)?     {
I20200519-15:39:59.451(8)?       "subject": {
I20200519-15:39:59.451(8)?         "interfaceName": "NamedNode",
I20200519-15:39:59.451(8)?         "attributes": [
I20200519-15:39:59.451(8)?           "interfaceName",
I20200519-15:39:59.451(8)?           "nominalValue"
I20200519-15:39:59.451(8)?         ],
I20200519-15:39:59.451(8)?         "nominalValue": {
I20200519-15:39:59.452(8)?           "token": "uri",
I20200519-15:39:59.452(8)?           "prefix": null,
I20200519-15:39:59.452(8)?           "suffix": "a",
I20200519-15:39:59.452(8)?           "value": null
I20200519-15:39:59.452(8)?         }
I20200519-15:39:59.452(8)?       },
I20200519-15:39:59.452(8)?       "predicate": {
I20200519-15:39:59.452(8)?         "interfaceName": "NamedNode",
I20200519-15:39:59.452(8)?         "attributes": [
I20200519-15:39:59.452(8)?           "interfaceName",
I20200519-15:39:59.452(8)?           "nominalValue"
I20200519-15:39:59.452(8)?         ],
I20200519-15:39:59.452(8)?         "nominalValue": {
I20200519-15:39:59.452(8)?           "token": "uri",
I20200519-15:39:59.452(8)?           "prefix": null,
I20200519-15:39:59.452(8)?           "suffix": "plays",
I20200519-15:39:59.452(8)?           "value": null
I20200519-15:39:59.453(8)?         }
I20200519-15:39:59.453(8)?       },
I20200519-15:39:59.453(8)?       "object": {
I20200519-15:39:59.453(8)?         "interfaceName": "NamedNode",
I20200519-15:39:59.453(8)?         "attributes": [
I20200519-15:39:59.453(8)?           "interfaceName",
I20200519-15:39:59.453(8)?           "nominalValue"
I20200519-15:39:59.453(8)?         ],
I20200519-15:39:59.453(8)?         "nominalValue": {
I20200519-15:39:59.453(8)?           "token": "uri",
I20200519-15:39:59.453(8)?           "prefix": null,
I20200519-15:39:59.453(8)?           "suffix": "管理员",
I20200519-15:39:59.453(8)?           "value": null
I20200519-15:39:59.453(8)?         }
I20200519-15:39:59.453(8)?       }
I20200519-15:39:59.453(8)?     }
I20200519-15:39:59.454(8)?   ],
I20200519-15:39:59.454(8)?   "duplicates": {
I20200519-15:39:59.454(8)?     "[object Object][object Object][object Object]": true
I20200519-15:39:59.454(8)?   },
I20200519-15:39:59.454(8)?   "actions": [],
I20200519-15:39:59.454(8)?   "length": 1
I20200519-15:39:59.454(8)? }

Issue testing this ontology

Hi,
I used Hylar to test this ontology with the OWL2RL entailment.
I get the following error that may be due to the fact that OWL2RL doesn't support the axiomatic triples (indeed it works with RDFS).
Can you help me to better understand the error log?

[HyLAR] Classification started.
[HyLAR] Registering derivations to dictionary...
[HyLAR] ✨ Registered successfully.
[HyLAR] Classification succeeded.
(node:5423) UnhandledPromiseRejectionWarning: SyntaxError: Expected [1] QueryUnit or [29] UpdateUnit but "I" found.
at peg$buildStructuredError (/home/mondeca/node_modules/rdfstore/src/parser.js:2760:14)
at Object.peg$parse [as parse] (/home/mondeca/node_modules/rdfstore/src/parser.js:19694:13)
at AbstractQueryTree.parseQueryString (/home/mondeca/node_modules/rdfstore/src/abstract_query_tree.js:32:29)
at QueryEngine.execute (/home/mondeca/node_modules/rdfstore/src/query_engine.js:597:49)
at Store.execute (/home/mondeca/node_modules/rdfstore/src/store.js:178:14)
at TripleStorageManager.query (/home/mondeca/node_modules/hylar/hylar/core/TripleStorageManager.js:50:22)
at TripleStorageManager.insert (/home/mondeca/node_modules/hylar/hylar/core/TripleStorageManager.js:97:26)
at Promise.reduce (/home/mondeca/node_modules/hylar/hylar/hylar.js:723:28)
at tryCatcher (/home/mondeca/node_modules/bluebird/js/release/util.js:16:23)
at Object.gotValue (/home/mondeca/node_modules/bluebird/js/release/reduce.js:168:18)
at Object.gotAccum (/home/mondeca/node_modules/bluebird/js/release/reduce.js:155:25)
at Object.tryCatcher (/home/mondeca/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/mondeca/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/home/mondeca/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromiseCtx (/home/mondeca/node_modules/bluebird/js/release/promise.js:641:10)
at _drainQueueStep (/home/mondeca/node_modules/bluebird/js/release/async.js:97:12)
(node:5423) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5423) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

PropertyChainAxiom

Hi,

I was trying to add an owl:propertyChainAxiom rule, but I can't get it to work.

The ontology is available here. It is loaded in and I have no problems inferring rules given by rdfs:subClassOf etc. I just can't get my own rule to work.

Triples:
@prefix bot: <https://w3id.org/bot#> . <levelA> bot:hasSpace <spaceA> . <spaceA> bot:containsElement <elementA> .

Test query:
PREFIX bot: <https://w3id.org/bot#> SELECT * WHERE { ?x bot:containsZone ?y . ?y bot:containsElement ?z . }

Hylar recognizes that bot:hasSpace is an rdfs:subPropertyOf bot:containsZone and returns a correct result:
[ { x: { token: 'uri', value: 'levelA' }, y: { token: 'uri', value: 'spaceA' }, z: { token: 'uri', value: 'elementA' } } ]

Before writing the general rule I wanted to test one for the specific case (which doesn't work):
(?z1 https://w3id.org/bot#containsZone ?z2) ^ (?z2 https://w3id.org/bot#containsElement ?el) -> (?z1 https://w3id.org/bot#containsElement ?el)

This general rule should work:
(?x ?p1 ?y) ^ (?p2 http://www.w3.org/2002/07/owl#propertyChainAxiom ?n) ^ (?n http://www.w3.org/1999/02/22-rdf-syntax-ns#first ?p1) ^ (?n http://www.w3.org/1999/02/22-rdf-syntax-ns#rest ?n2) ^ (?n2 http://www.w3.org/1999/02/22-rdf-syntax-ns#first ?p2) ^ (?y ?p2 ?z) -> (?x ?p2 ?z)

Thanks for sharing your work. From what I know this is the only OWL2 reasoner for JavaScript.

empty result sets

@mterdjimi

tired some basic code, but empty result sets

onto

@prefix : <http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40> .

<http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40> rdf:type owl:Ontology .

#################################################################
#    Data properties
#################################################################

###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#field1
:field1 rdf:type owl:DatatypeProperty .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#可食用
:可食用 rdf:type owl:DatatypeProperty .


#################################################################
#    Classes
#################################################################

###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#动物
:动物 rdf:type owl:Class ;
    rdfs:subClassOf [ rdf:type owl:Restriction ;
                      owl:onProperty :可食用 ;
                      owl:hasValue ""
                    ] .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#可食用的东西
:可食用的东西 rdf:type owl:Class ;
        owl:hasKey ( :field1
                   ) ,
                   ( :可食用
                   ) .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#橙子
:橙子 rdf:type owl:Class ;
    rdfs:subClassOf :水果 .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#水果
:水果 rdf:type owl:Class ;
    rdfs:subClassOf [ rdf:type owl:Restriction ;
                      owl:onProperty :可食用 ;
                      owl:hasValue ""
                    ] .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#牛
:牛 rdf:type owl:Class ;
   rdfs:subClassOf :动物 .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#猪
:猪 rdf:type owl:Class ;
   rdfs:subClassOf :动物 .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#羊
:羊 rdf:type owl:Class ;
   rdfs:subClassOf :动物 .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#苹果
:苹果 rdf:type owl:Class ;
    rdfs:subClassOf :水果 .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#葡萄
:葡萄 rdf:type owl:Class ;
    rdfs:subClassOf :水果 .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#香蕉
:香蕉 rdf:type owl:Class ;
    rdfs:subClassOf :水果 .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#鸡
:鸡 rdf:type owl:Class ;
   rdfs:subClassOf :动物 .


#################################################################
#    Individuals
#################################################################

###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#橙子1
:橙子1 rdf:type owl:NamedIndividual ;
     :field1 123123 ;
     :可食用 "" .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#苹果1
:苹果1 rdf:type owl:NamedIndividual ;
     :可食用 "" .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#苹果2
:苹果2 rdf:type owl:NamedIndividual ;
     :可食用 "" .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#葡萄1
:葡萄1 rdf:type owl:NamedIndividual ;
     :可食用 "" .


###  http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#香蕉1
:香蕉1 rdf:type owl:NamedIndividual ;
     :可食用 "" .


#################################################################
#    General axioms
#################################################################

[ rdf:type owl:AllDifferent ;
  owl:distinctMembers ( :橙子1
                        :苹果1
                        :苹果2
                        :葡萄1
                        :香蕉1
                      )
] .


###  Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi

code

const fs = require('fs')
const Hylar = require('hylar')

const rawOntology = fs.readFileSync('./db.owl', { encoding: 'utf-8' })

const h = new Hylar()

h.load(rawOntology, 'text/turtle', false)

main()

async function main () {
  const query = `
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX owl: <http://www.w3.org/2002/07/owl#>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    PREFIX : <http://www.semanticweb.org/monsterstep/ontologies/2020/4/untitled-ontology-40#>
    SELECT * WHERE {
      ?s ?p ?o
    }
  `
  let results = await h.query(query)

  console.log(results)
}

image

Cannot initialize Hylar in a browser

Hi there, I've tried to use Hylar-reasoner in a stand-alone browse as follows:

index.html:

<script language="javascript" type="text/javascript" src="/resources/js/hylar/hylar-client.js"></script> <script> h = new Hylar(); </script>

But just get this error: ReferenceError: Hylar is not defined

What am I doing wrong? I'm not using node neither bower nor anything. Just a plain call to the JS file.

not working with node8

Hi ,
I am installing this package in my application with npm install --save hylar and getting following error.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  contextify.cc
  win_delay_load_hook.cc
..\src\contextify.cc(150): error C2039: 'SetAccessCheckCallbacks': is not a member of 'v8::ObjectTemplate' [C:\Us ers\csainik\proj\g4\algo-crosshairs\node_modules\contextify\build\contextify.vcxproj]

my environment details are as follows
OS- window 7
and

node --version
v8.0.0

and

npm --version
5.0.0

install [email protected] failed

npm install --save hylar
npm ERR! code 128
npm ERR! Command failed: git clone --mirror -q https://github.com/mterdjimi/rdfstore-js.git /Users/monsterstep/.npm/_cacache/tmp/git-clone-94754f51/.git
npm ERR! warning: templates not found in /var/folders/g_/9zn58k_16m50w1z3tqvq65xr0000gn/T/pacote-git-template-tmp/git-clone-60c34e39
npm ERR! error: RPC failed; curl 18 transfer closed with outstanding read data remaining
npm ERR! fatal: the remote end hung up unexpectedly
npm ERR! fatal: early EOF
npm ERR! fatal: index-pack failed
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/monsterstep/.npm/_logs/2020-05-15T05_30_07_762Z-debug.log
dev/owl-playground/hylar is 📦  v1.0.0 via ⬢ v14.2.0 took 1m 58s
👽 node -v
v14.2.0

dev/owl-playground/hylar is 📦  v1.0.0 via ⬢ v14.2.0
👽 npm -v
6.14.4

i've tried node 10 and 12

all failed

add PREFIX Support to parseAndAddRule

something like this would be awesome

h.parsePrefix('http://un.jong.kim/onto#', ':')
h.parsePrefix('http://un.jong.kim/onto#', 'default')

(?x :hasChild ?y) -> (?x a :Person)

add an rule but no new tripples

const fs = require('fs')
const Hylar = require('hylar')
const h = new Hylar()
const file = fs.readFileSync('./kg.ttl', { encoding: 'utf-8' })

const PREFIX = IRI => `http://un.jong.kim/onto#${IRI}`

async function test() {
  const kg = await h.load(file, 'text/turtle')
  h.parseAndAddRule(`(?x http://un.jong.kim#hasChild ?y) ^ (?y http://un.jong.kim/onto#hasChild ?z) -> (?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://un.jong.kim/onto#GrandFather)`, 'R1')
  const test = await squery(`select * where { ?s ?p ?o . }`)
  console.log(test)
}

test()

async function squery(q) {
  return await h.query(`
    PREFIX : <http://un.jong.kim/onto#>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    ${q}
  `)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.