Created
November 13, 2021 14:44
-
-
Save anatoly-scherbakov/ebde3d6b70ddde7f7b3baadb65d8464b to your computer and use it in GitHub Desktop.
OWL RL creates invalid triples when working on PROV-O ontology
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import sys | |
import owlrl | |
import rdflib | |
from owlrl import OWLRL_Extension | |
from rdflib import Graph, Literal | |
logger = logging.getLogger(__name__) | |
def find_literal_subject_triples(graph: Graph): | |
return list( | |
filter( | |
lambda triple: isinstance(triple[0], Literal), | |
graph, | |
), | |
) | |
def test_owlrl_literal_subject(): | |
logger.info(sys.version) | |
logger.info('rdflib=={}'.format( | |
rdflib.__version__, | |
)) | |
logger.info('owlrl=={}'.format( | |
owlrl.__version__, | |
)) | |
graph = Graph() | |
graph.parse('http://www.w3.org/ns/prov#') | |
assert not find_literal_subject_triples(graph), ( | |
'Import of PROV-O ontology creates triples where Literal is a subject.' | |
) | |
owlrl.DeductiveClosure(OWLRL_Extension).expand(graph) | |
literal_triples = find_literal_subject_triples(graph) | |
assert not literal_triples, ( | |
'OWL RL creates triples with literal as subject. Example: {t}'.format( | |
t=literal_triples[0], | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: