GithubHelp home page GithubHelp logo

rdflib / owl-rl Goto Github PK

View Code? Open in Web Editor NEW
134.0 21.0 30.0 6.99 MB

A simple implementation of the OWL2 RL Profile on top of RDFLib: it expands the graph with all possible triples that OWL RL defines. It can be used together with RDFLib to expand an RDFLib Graph object, or as a stand alone service with its own serialization.

Home Page: http://www.ivan-herman.net/Misc/2008/owlrl/

License: Other

CSS 0.90% Python 6.17% HTML 92.62% JavaScript 0.30%
rdflib owl-rl python inference reasoning owl rdf

owl-rl's Introduction

Original Author DOI PyPI badge

OWL-RL Logo

OWL-RL

A simple implementation of the OWL2 RL Profile, as well as a basic RDFS inference, on top of RDFLib. Based mechanical forward chaining. The distribution contains:

OWL-RL: the Python library. You should copy the directory somewhere into your PYTHONPATH. Alternatively, you can also run the python setup.py install script in the directory.

  • scripts/RDFConvertService: can be used as a CGI script to invoke the library. It may have to be adapted to the local server setup.
  • scripts/owlrl: script that can be run locally on to transform a file into RDF (on the standard output). Run the script with -h to get the available flags.

The package requires Python version 3.5 or higher; it depends on RDFLib; version 4.2.2 or higher is required. If you need the python 2.7.x compatible version, see the @/py2 branch in this repository.

For the details on RDFS, see the RDF Semantics Specification; for OWL 2 RL, see the OWL 2 Profile specification.

View the OWL-RL documentation online: http://owl-rl.readthedocs.io/

To view the changelog for this software library, see CHANGELOG.rst.

This software is released under the W3C© SOFTWARE NOTICE AND LICENSE. See LICENSE.txt.

owl-rl's People

Contributors

aidhog avatar aniket-pradhan avatar ashleysommer avatar edmondchuc avatar iherman avatar jiahao avatar maparent avatar nicholascar avatar wrobell 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

owl-rl's Issues

6.0.2: pytest warnings

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-owlrl-6.0.2-%autorelease.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-owlrl-6.0.2-%autorelease.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.18, pytest-7.4.4, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2
collected 17 items

test/test_basic.py .                                                                                                                                                                  [  5%]
test/test_class_axioms.py .                                                                                                                                                           [ 11%]
test/test_classes.py ........                                                                                                                                                         [ 58%]
test/test_datatypes.py ...                                                                                                                                                            [ 76%]
test/test_equality.py .                                                                                                                                                               [ 82%]
test/test_owlrl_extras.py .                                                                                                                                                           [ 88%]
test/test_rdfs_closure.py ..                                                                                                                                                          [100%]

===================================================================================== warnings summary ======================================================================================
../../../../../usr/lib/python3.8/site-packages/_pytest/compat.py:328
  /usr/lib/python3.8/site-packages/_pytest/compat.py:328: UserWarning: Code: _pytestfixturefunction is not defined in namespace XSD
    return getattr(object, name, default)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=============================================================================== 17 passed, 1 warning in 0.81s ===============================================================================

RDFS_Semantics add predicate datatype values from unrelated subjects

Running version 6.0.2. In this example, after running the closure, both ex:alpha and ex:beta has both 42 and 22 under the ex:hasValue predicate.

from rdflib import Graph
from owlrl import DeductiveClosure, RDFS_Semantics

input_ttl = """
@prefix ex: <urn:example#> .
ex:alpha ex:hasValue "42"^^ex:Blorb .
ex:beta ex:hasValue "22"^^ex:Blorb .
"""

g = Graph()
g.parse(data=input_ttl, format='turtle')
DeductiveClosure(RDFS_Semantics).expand(g)
print(g.serialize(format='turtle'))

Owlrl -w pos-cleaning

(Sorry if I'm putting this message in the wrong place...)

Thank you guys for owlrl tool / package!
I am trying to use it and I get (almost) all a I need with

owlrl -w archive.ttl > expanded.ttl

but I always have to write a cleaning tool the removes things like:

  • all reflexive triples, most of them related to owl:someAs

    "1951-05-12" owl:someAs "1951-05-12" .          // a simple value from a data property
    
  • triples with subject owl:... xds:... rdf:....

    rdf:HTML a rdfs:Datatype;
                owl:sameAs rdf:HTML .                          // not used anywhere
    

    Is there any easy way to delete them ?

Please ignore the previous :

with owlrl -m archive.ttl > expanded.ttl I get the cleaned version.

Remove `LiteralProxies` class to improve the performance of processing

The RDFClosure/Literals.py states

The issue is that pure literals cannot appear in subject position according to the current rules on RDF. That means that different types of conclusions cannot properly finish.

However, rdflib seems to support literals in subject position.

I wonder if we could remove LiteralProxies class and therefore speedup the whole processing?

6.0.2: sphinx warnings `reference target not found`

On building my packages I'm using sphinx-build command with -n switch which shows warmings about missing references. These are not critical issues.
Here is the output with warnings:

+ /usr/bin/sphinx-build -n -T -b man docs/source build/sphinx/man
Running Sphinx v7.1.2
WARNING: Invalid configuration value found: 'language = None'. Update your configuration to a valid language code. Falling back to 'en' (English).
making output directory... done
WARNING: html_static_path entry '_static' does not exist
WARNING: The pre-Sphinx 1.0 'intersphinx_mapping' format is deprecated and will be removed in Sphinx 8. Update to the current format as described in the documentation. Hint: "intersphinx_mapping = {'<name>': ('https://docs.python.org/', None)}".https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_mapping
loading intersphinx inventory from https://docs.python.org/objects.inv...
intersphinx inventory has moved: https://docs.python.org/objects.inv -> https://docs.python.org/3/objects.inv
[autosummary] generating autosummary for: AxiomaticTriples.rst, AxiomaticTriples_source.rst, Closure.rst, CombinedClosure.rst, DatatypeHandling.rst, DatatypeHandling_source.rst, OWLRL.rst, OWLRLExtras.rst, RDFSClosure.rst, RestrictedDatatype.rst, XsdDatatypes.rst, XsdDatatypes_source.rst, index.rst, indices_and_tables.rst, installation.rst, owlrl.rst, stubs/owlrl.Closure.rst, stubs/owlrl.DeductiveClosure.rst, stubs/owlrl.rst, usage.rst
building [mo]: targets for 0 po files that are out of date
writing output...
building [man]: all manpages
updating environment: [new config] 20 added, 0 changed, 0 removed
reading sources... [100%] usage
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:103: ERROR: Unexpected indentation.
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:104: WARNING: Literal block ends without a blank line; unexpected unindent.
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.interpret_owl_imports:8: WARNING: Field list ends without a blank line; unexpected unindent.
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:103: ERROR: Unexpected indentation.
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:104: WARNING: Literal block ends without a blank line; unexpected unindent.
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:1: WARNING: duplicate object description of owlrl, other instance in OWLRL, use :noindex: for one of them
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.DeductiveClosure:1: WARNING: duplicate object description of owlrl.DeductiveClosure, other instance in OWLRL, use :noindex: for one of them
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.DeductiveClosure.expand:1: WARNING: duplicate object description of owlrl.DeductiveClosure.expand, other instance in OWLRL, use :noindex: for one of them
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.DeductiveClosure.improved_datatype_generic:1: WARNING: duplicate object description of owlrl.DeductiveClosure.improved_datatype_generic, other instance in OWLRL, use :noindex: for one of them
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.DeductiveClosure.use_improved_datatypes_conversions:1: WARNING: duplicate object description of owlrl.DeductiveClosure.use_improved_datatypes_conversions, other instance in OWLRL, use :noindex: for one of them
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.DeductiveClosure.use_rdflib_datatypes_conversions:1: WARNING: duplicate object description of owlrl.DeductiveClosure.use_rdflib_datatypes_conversions, other instance in OWLRL, use :noindex: for one of them
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.convert_graph:1: WARNING: duplicate object description of owlrl.convert_graph, other instance in OWLRL, use :noindex: for one of them
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.interpret_owl_imports:1: WARNING: duplicate object description of owlrl.interpret_owl_imports, other instance in OWLRL, use :noindex: for one of them
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.interpret_owl_imports:8: WARNING: Field list ends without a blank line; unexpected unindent.
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.return_closure_class:1: WARNING: duplicate object description of owlrl.return_closure_class, other instance in OWLRL, use :noindex: for one of them
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:103: ERROR: Unexpected indentation.
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:104: WARNING: Literal block ends without a blank line; unexpected unindent.
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:1: WARNING: duplicate object description of owlrl, other instance in owlrl, use :noindex: for one of them
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/Closure.py:docstring of owlrl.Closure:1: WARNING: duplicate object description of owlrl.Closure, other instance in Closure, use :noindex: for one of them
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.DeductiveClosure:1: WARNING: duplicate object description of owlrl.DeductiveClosure, other instance in owlrl, use :noindex: for one of them
looking for now-outdated files... none found
pickling environment... done
checking consistency... /home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/docs/source/AxiomaticTriples_source.rst: WARNING: document isn't included in any toctree
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/docs/source/DatatypeHandling_source.rst: WARNING: document isn't included in any toctree
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/docs/source/XsdDatatypes_source.rst: WARNING: document isn't included in any toctree
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/docs/source/stubs/owlrl.rst: WARNING: document isn't included in any toctree
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/docs/source/stubs/owlrl.Closure.rst: WARNING: document isn't included in any toctree
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/docs/source/stubs/owlrl.DeductiveClosure.rst: WARNING: document isn't included in any toctree
done
writing... python-owl-rl.3 { installation usage indices_and_tables owlrl AxiomaticTriples Closure CombinedClosure DatatypeHandling OWLRL OWLRLExtras RDFSClosure RestrictedDatatype XsdDatatypes } /home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:60: WARNING: py:class reference target not found: OWLRL.OWLRL_Semantics
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:80: WARNING: py:class reference target not found: OWLRL.OWLRL_Semantics
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:87: WARNING: py:class reference target not found: Literals.LiteralProxies
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.DeductiveClosure:1: WARNING: py:class reference target not found: OWLRL_Semantics
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.DeductiveClosure.expand:4: WARNING: py:class reference target not found: rdflib.Graph
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.interpret_owl_imports:12: WARNING: py:class reference target not found: RDFLib.Graph
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/Closure.py:docstring of owlrl.Closure.Core:4: WARNING: py:class reference target not found: OWLRL.OWLRL_Semantics
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/Closure.py:docstring of owlrl.Closure.Core:24: WARNING: py:class reference target not found: rdflib.Graph
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/Closure.py:docstring of owlrl.Closure.Core.closure:3: WARNING: py:func reference target not found: Core.store_triple
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/Closure.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: s
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/Closure.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: p
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/Closure.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: o
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/CombinedClosure.py:docstring of owlrl.CombinedClosure.RDFS_OWLRL_Semantics:1: WARNING: py:class reference target not found: owlrl.OWLRL.OWLRL_Semantics
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/CombinedClosure.py:docstring of owlrl.CombinedClosure.RDFS_OWLRL_Semantics:12: WARNING: py:class reference target not found: rdflib.Graph
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/CombinedClosure.py:docstring of owlrl.Closure.Core.closure:3: WARNING: py:func reference target not found: Core.store_triple
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/CombinedClosure.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: s
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/CombinedClosure.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: p
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/CombinedClosure.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: o
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/DatatypeHandling.py:docstring of owlrl.DatatypeHandling.use_Alt_lexical_conversions:1: WARNING: py:data reference target not found: AltXSDToPYTHON
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:60: WARNING: py:class reference target not found: OWLRL.OWLRL_Semantics
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:80: WARNING: py:class reference target not found: OWLRL.OWLRL_Semantics
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl:87: WARNING: py:class reference target not found: Literals.LiteralProxies
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.DeductiveClosure:1: WARNING: py:class reference target not found: OWLRL_Semantics
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.DeductiveClosure.expand:4: WARNING: py:class reference target not found: rdflib.Graph
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/__init__.py:docstring of owlrl.interpret_owl_imports:12: WARNING: py:class reference target not found: RDFLib.Graph
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.OWLRLExtras.OWLRL_Extension:1: WARNING: py:func reference target not found: _strToRational
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.OWLRLExtras.OWLRL_Extension.add_axioms:1: WARNING: py:class reference target not found: OWLRL_Extension.extra_axioms
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.Closure.Core.closure:3: WARNING: py:func reference target not found: Core.store_triple
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: s
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: p
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: o
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.OWLRLExtras.OWLRL_Extension_Trimming:22: WARNING: py:class reference target not found: rdflib.Graph
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.OWLRLExtras.OWLRL_Extension.add_axioms:1: WARNING: py:class reference target not found: OWLRL_Extension.extra_axioms
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.Closure.Core.closure:3: WARNING: py:func reference target not found: Core.store_triple
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: s
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: p
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/OWLRLExtras.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: o
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/RDFSClosure.py:docstring of owlrl.RDFSClosure.RDFS_Semantics:15: WARNING: py:class reference target not found: rdflib.Graph
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/RDFSClosure.py:docstring of owlrl.Closure.Core.closure:3: WARNING: py:func reference target not found: Core.store_triple
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/RDFSClosure.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: s
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/RDFSClosure.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: p
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/RDFSClosure.py:docstring of owlrl.Closure.Core.store_triple:1: WARNING: py:class reference target not found: o
/home/tkloczko/rpmbuild/BUILD/OWL-RL-6.0.2/owlrl/RestrictedDatatype.py:docstring of owlrl.RestrictedDatatype.extract_faceted_datatypes:7: WARNING: py:class reference target not found: RDFLib.Graph
done
build succeeded, 72 warnings.

You can peak on fixes that kind of issues in other projects
RDFLib/rdflib-sqlalchemy#95
RDFLib/rdflib#2036
click-contrib/sphinx-click@abc31069
frostming/unearth#14
jaraco/cssutils#21
latchset/jwcrypto#289
latchset/jwcrypto#289
pypa/distlib@98b9b89f
pywbem/pywbem#2895
sissaschool/elementpath@bf869d9e
sissaschool/xmlschema@42ea98f2
sqlalchemy/sqlalchemy@5e88e6e8

Test fails: test_cls_maxqc1

Hey all! I am trying to package OWL-RL for the Fedora OS and am struggling through one of the test cases that is failing (even in a virtual environment).

The test case is: test_cls_maxqc1 from test/test_classes.py. Below is the error log for the same.

def test_cls_maxqc1():
        """
        Test cls-maxqc1 rule for OWL 2 RL.
    
        If::
    
            T(?x, owl:maxQualifiedCardinality, "0"^^xsd:nonNegativeInteger)
            T(?x, owl:onProperty, ?p)
            T(?x, owl:onClass, ?c)
            T(?u, rdf:type, ?x)
            T(?u, ?p, ?y)
            T(?y, rdf:type, ?c)
    
        then::
    
            false
        """
        g = Graph()
    
        x = T.x
        p = T.p
        c = T.C
        u = T.u
        y = T.y
    
        g.add((x, OWL.maxQualifiedCardinality, Literal(0)))
        g.add((x, OWL.onProperty, p))
        g.add((x, OWL.onClass, c))
        g.add((u, p, y))
        g.add((y, RDF.type, c))
    
        owlrl.DeductiveClosure(owlrl.OWLRL_Semantics).expand(g)
>       result = next(g.objects(predicate=DAML.error))
E       StopIteration

test/test_classes.py:123: StopIteration

Now, from what I know, the variable g should be a generator object but it is apparently empty/exhausted. I am pretty sure that it should not be like that but am unable to figure out the root problem here.

I will be happy to help if needed. :D

My Python version is 3.9.1 and below are the versions of the installed deps.

attrs==20.3.0
iniconfig==1.1.1
isodate==0.6.0
owlrl==5.2.1
packaging==20.9
pluggy==0.13.1
py==1.10.0
pyparsing==3.0.0b2
pytest==6.2.2
rdflib==5.0.0
rdflib-jsonld==0.5.0
six==1.15.0
toml==0.10.2

Include the updated license text in the source.

Hello Devs

I was packaging OWL-RL in the Fedora OS, and as per our guidelines, the source code should contain the full license text in it.

Furthermore, I checked out LICENSE.txt and it links to an older version of the W3C License. The license was renamed to "software and document" license in 2015 and can be found here
You can check out the disclaimer on the page the current license links to.

license compatibility

I've spend some time searching the web, but I am not quite sure:

Is it okay to relience the code (aka reuse) in a project under a different license (namely bsd-3-clause, like rdflib)?

While the w3c license faq states:

Is code released under the W3C license compatible with non-copyleft / proprietary licenses?
Yes. The W3C license permits W3C code to be used in other (non-copyleft) licenses or even proprietary software.

Reading the license it seems not possible as the notice requirement seem more elaborate on the w3c license than the bsd-3-clause.

Debian/Ubuntu package for owlrl

In late 2018 we achieved a lot with OWL-RL.
We successfully released v5.0, we ported it to python3, changed the python package name from RDFClosure to owlrl, and we got the package published on pypi.

Now its 2019 and its time for the next milestone.

I want to get owlrl packaged as a debian package and available from the official debian repositories, and in turn into Ubuntu repositories.

This is a necessary step in my plan to get pySHACL available in debian. PySHACL has two dependencies, rdflib and owlrl. RDFLib is already packaged and available in the debian repositories, so I need to get owlrl in too before I can package and publish a pySHACL debian package.

I've already submitted an ITP (Intent to Package) for owlrl and pySHACL, to the Debian WNPP list.
I've created an Uploader account on the Debain Mentors site, so that I can request a sponsor to sponsor the package (to authorize it on my behalf) once the package is uploaded to the Mentors site staging area.

Unexpected behaviour of OWL-RL reasoner (Literals in the position of Subjects)

This problem has been reported in #50, but there it has been reported as a problem on PROV-O.

The problem seems to be more generic than that. The following is a minimal example:

@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https:example.org/A> dcterms:issued "2018-06-21T12:00:00"^^xsd:dateTime .

The augmented graph contains the following (offensive) inferred triple:

"2018-06-21T12:00:00"^^xsd:dateTime a xsd:dateTime ;
    owl:sameAs "2018-06-21T12:00:00"^^xsd:dateTime .

This type of inferred facts would cause the graph to be unparseable in some triplestores. In GraphDB, for instance, one gets a parsing error.

Other OWL-RL reasoners, like the one from GraphDB, do not generate statements with literals as the first component of a triple.

The version used was owlrl==6.0.2

The ticket #13 seems to aim to solve this, but is it open since 2018.
Are there any plans to fix it?

`owlrl --help` in 6.x fails, trying to import old constants (e.g. RDFXML)

Discovered on conda-forge where we execute owlrl --help as part of the tests, It looks like the scripts were not updated for 6.x, after the removal of all of the various format strings were removed:

Traceback (most recent call last):
  File "/home/conda/feedstock_root/build_artifacts/owlrl_1633874681694/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/bin/owlrl", line 6, in <module>
    from owlrl._cli import main
  File "/home/conda/feedstock_root/build_artifacts/owlrl_1633874681694/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/lib/python3.9/site-packages/owlrl/_cli.py", line 5, in <module>
    from owlrl import convert_graph, RDFXML, TURTLE, JSON, AUTO, RDFA
ImportError: cannot import name 'RDFXML' from 'owlrl' (/home/conda/feedstock_root/build_artifacts/owlrl_1633874681694/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/lib/python3.9/site-packages/owlrl/__init__.py)

As I know folk actually do use the command line tool, I'm probably just not going to ship that release on conda-forge.

Related:

  • We patch the scripts in setup.py to be cross-platform entry_points
    • the 6.x line may be an appropriate time to change this
      • and potentially add this to the test suite
  • Another nice thing would be a --version CLI flag

Unable to run closure.py script after installation from PyPI

To reproduce on Linux

  1. Install owlrl with pip install --user owlrl.
  2. Run ~/.local/bin/closure.py.
  3. You will get the error like
$ ~/.local/bin/closure.py            
mksh: /home/wrobell/.local/bin/closure.py: No such file or directory

The reason for that is first line in the script

#!/home/flubba86/PycharmProjects/OWL-RL/venv/bin/python3

However in the repository the line is OK. It seems owlrl needs to be released without overrides from a local environment (BTW. new release is needed then as PyPI does not allow to re-upload file with same name and different checksum if I remember well).

As workaround run

python3 ~/.local/bin/closure.py

Solving Einstein's riddle (zebra puzzle)

Dear all,

there are two known implementations of the famous Einstein's riddle (zebra puzzle) in OWL:

Unlike Protégé, this brute-force reasoner fails to solve both of these implementations (an expanded graph does not contain any triples connecting zebra and Japanese, which is an answer).

Is it an expected behavior?

Introduce inference and optimization for dt-diff

The inference for dt-diff rule is missing in OWL-RL at the moment (see https://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules for the rule definition).

The rule is important, because it allows to infer an error when a subject and predicate (data property) violate the 1 max cardinality. For example

  • triple 1: (s, p, 11)
  • triple 2: (s, p, 12)
  • rule cls-maxc2: (11, owl:sameAs, 12)
  • rule dt-diff (missing at the moment): (11, owl:differentFrom, 12)
  • rule eq-diff1 (not triggered due to dt-diff missing): false

Because dt-diff is not implemented we end up with (11, owl:sameAs, 12) in the graph only - this is without the (11, owl:differentFrom, 12) and the error.

We could implement inference for dt-diff, but it will create a lot of trivial triples in a graph. We should probably immediately optimise this and whenever we have triples like (s, p, l1) and (s, p, l2) generate an error avoiding generation of dt-diff and cls-maxc2 triples.

Domain (and range) of rdfs:subClassOf

I try to extend the following fragment

    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix hsh: <http://hsh.de/bim3#> .
    
    rdfs:subClassOf rdfs:domain rdfs:Class .

    hsh:dog  rdfs:subClassOf hsh:animal.

In the extended graph, now there is a statement:

hsh:dog a rdfs:Class,
        rdfs:Resource ;
    rdfs:subClassOf hsh:animal,
        hsh:dog,
        rdfs:Resource .

This is what I expected. However, wehen I leave out the first triple (rdfs:subClassOf rdfs:domain rdfs:Class .) which is already part of rdfs definition, the result does not include the fact that hsh:dog a rdfs:Class anymore. Is this a feature or a bug?

Enable selection of other OWL reasoning profiles - EL, QL

EL & QL reasoning should use fewer rules than RL and thus this tookit should be able to implement them since it can already do RL. Having EL, QL & RL as options will allow people to see the different results that these profiles actually produce, rather than having to just look at the profile definitions.

(RDFS) Closure is flushed to the graph

import owlrl

rdfs = owlrl.RDFSClosure.RDFS_Semantics(g, False, False, False)
rdfs.closure()

result = g.query("""
PREFIX s: <http://example.org/>
SELECT ?x
WHERE{
    ?x rdf:type s:Example .
} 
""")

print(g.serialize())

When I understood the documentation correctly, calling rdfs.closure() should only store the inferred triples in a temporary set. They should only be added to the graph when calling the flush_stored_triples() method.
However, this method is already called at the end of the closure() method.

Is there a possibility to not add the triples directly to the graph? Is this behavior on purpose?

Create inferred triples in a NAMED graph

When using an rdflib.ConjunctiveGraph, OWL-RL creates its inferred triples in the default, unnamed graph.

Is it possible to create them in a specific named graph instead, if so requested by the user?

rdflib_jsonld breaks install, replace with RDFLib 6.0 integrated version

A big change in RDFlib 6.0 was integrating rdflib_jsonld into RDFlib itself: RDFLib/rdflib#1354

Due to this, the rdflib_jsonld project has been archived and is not maintained anymore: https://github.com/RDFLib/rdflib-jsonld#archived

Since rdflib_jsonld cannot be installed anymore with the newest version of setuptools, since it has use_2to3 set to true, see pypa/setuptools#2769, this makes OWL-RL uninstallable with JSON-LD with the newest version of setuptools.

I noticed this when trying to work on a PR for pySHACL to fix the same issue: RDFLib/pySHACL#93

UserWarning: Code: <SomeCode> is not defined in namespace XSD with rdflib 6.0.0

After installing owlrl, either alone or via installing pyshacl, a user is presented with a series of warnings on import:

Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import owlrl
RDFLib Version: 6.0.0
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/__init__.py:177: UserWarning: Code: dateTimeStamp is not defined in namespace XSD
  from . import DatatypeHandling, Closure
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/RDFSClosure.py:40: UserWarning: Code: dateTimeStamp is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/RDFSClosure.py:40: UserWarning: Code: length is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/RDFSClosure.py:40: UserWarning: Code: maxExclusive is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/RDFSClosure.py:40: UserWarning: Code: maxInclusive is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/RDFSClosure.py:40: UserWarning: Code: maxLength is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/RDFSClosure.py:40: UserWarning: Code: minExclusive is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/RDFSClosure.py:40: UserWarning: Code: minInclusive is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/RDFSClosure.py:40: UserWarning: Code: minLength is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/RDFSClosure.py:40: UserWarning: Code: pattern is not defined in namespace XSD
  from owlrl.AxiomaticTriples import RDFS_Axiomatic_Triples, RDFS_D_Axiomatic_Triples
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/OWLRL.py:53: UserWarning: Code: dateTimeStamp is not defined in namespace XSD
  from .XsdDatatypes import OWL_RL_Datatypes, OWL_Datatype_Subsumptions
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/OWLRLExtras.py:64: UserWarning: Code: dateTimeStamp is not defined in namespace XSD
  from .RestrictedDatatype import extract_faceted_datatypes
>>> owlrl.__version__
'5.2.1'

These warnings are the result of the 6.0.0 release of rdflib.

The warnings are particularly bothersome when attempting to run pyshacl (https://github.com/RDFLib/pySHACL) at the command line (shortened below):

$ pyshacl
/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/__init__.py:177: UserWarning: Code: dateTimeStamp is not defined in namespace XSD
  from . import DatatypeHandling, Closure

[Many warnings removed]

/Users/tmitchel/Projects/sd2/pySBOL3/venv3/lib/python3.8/site-packages/owlrl/OWLRLExtras.py:64: UserWarning: Code: dateTimeStamp is not defined in namespace XSD
  from .RestrictedDatatype import extract_faceted_datatypes
usage: pyshacl [-h] [-s [SHACL]] [-e [ONT]] [-i {none,rdfs,owlrl,both}] [-m] [-im] [-a] [-j] [-it] [--abort] [-w] [-d]
               [-f {human,turtle,xml,json-ld,nt,n3}] [-df {auto,turtle,xml,json-ld,nt,n3}] [-sf {auto,turtle,xml,json-ld,nt,n3}]
               [-ef {auto,turtle,xml,json-ld,nt,n3}] [-V] [-o [OUTPUT]]
               DataGraph
pyshacl: error: the following arguments are required: DataGraph

Can something be done about these warnings?

Inferencing does not work on rdflib.Dataset

Inferencing does not work on rdflib.Dataset, yet rdflib.ConjunctiveGraph works just fine.

from rdflib.graph import Dataset, ConjunctiveGraph

from owlrl import DeductiveClosure
from owlrl.OWLRL import OWLRL_Semantics

# works
g1 = ConjunctiveGraph()
DeductiveClosure(OWLRL_Semantics).expand(g1)
print(len(g1))

# ValueError
g2 = Dataset()
DeductiveClosure(OWLRL_Semantics).expand(g2)
print(len(g2))

The exception is caused by the attempt to unpack with too many values in owlrl.OWLRL.py line 446.

Apparently this is due to how rdflib.Dataset and rdflib.ConjunctiveGraph handle triples/quads internally.

Reproducable - RDFS Inferencing crashes with KeyError

RDFS Inferencing crashes when it encounters a value that is an RDF Literal with an appended datatype which is not in list of datatypes that the RDFS Semantic Ruleset knows how to handle.

This is an example of a Graph which will trigger this error.
https://github.com/TopQuadrant/shacl/blob/master/src/test/resources/sh/tests/core/property/qualifiedValueShape-001.test.ttl
Notice that file has a Triple like this:

ex:subject1 ex:related_type "has-component"^^ex:code

The datatype ex:code does not exist in the graph, but even if it did, the RDFS Semantic Ruleset does not have an entry in its RDF-to-Python literal table for ex:code thus crashes with a KeyError.

This is on the py3 branch, I'm not sure if the same problem occurs in the old Py2.7 version.

Use better name for closure.py script

According to PyPI description of the script, the script performs conversion. That would suggest owlrl-convert script. But it also performs OWL 2 RL inference. So what about simply owlrl or owlrl-lint?

Rename OWL-RL to OWLInf

OWL-RL's original goal was to perform OWL-RL reasoning so "OWL-RL" has been an appropriate name. If other reasoning profiles are added, and RDFS is already available, then the name could/should be changed.

I propose to change the name to OWLInf, for OWL Inferencer.

cannot import name 'convert_graph' from 'owlrl'

As reported by a pySHACL user @ChrisGithubWork in this issue: RDFLib/pySHACL#19
On windows, when pyshacl issues from owlrl import convert_graph, python tries to import it from the owlrl.py command-line script file, rather than the module named owlrl.

I don't know if that happens on all windows installations? Nobody else has reported anything similar.
Perhaps it is only an issue if the "C:\Python35\Scripts" directory is in the PYTHON_PATH?

Anyway, this will probably go away in the next release of OWL-RL because the commandline script files no longer have a .py extension (to be more compatible with Debian packaging) so in theory that would cause python to not try to import that file as a module anymore.

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.