Giter VIP home page Giter VIP logo

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

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.

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)

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.

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.

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

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}
  `)
}

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.

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)? }

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

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

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.

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 .

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!

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.