Skip to content

Fixes error loading ontology from rdflib.Graph#184

Merged
nicholascar merged 1 commit intoRDFLib:masterfrom
yum-yab:master
May 29, 2023
Merged

Fixes error loading ontology from rdflib.Graph#184
nicholascar merged 1 commit intoRDFLib:masterfrom
yum-yab:master

Conversation

@yum-yab
Copy link
Contributor

@yum-yab yum-yab commented Mar 8, 2023

Hi, I tried using this library in combination with rdflib (version 6.2.0) and I found a bug, that occurs when you pass an instance of an rdflib.Graph into the constructor of pylode.OntDoc:

import pylode
import rdflib

graph = rdflib.Graph()
graph.parse("https://akswnc7.informatik.uni-leipzig.de/dstreitmatter/archivo/bdi.si.ehu.es/bdi--ontologies--ExtruOnt--ExtruOnt/2020.12.14-144514/bdi--ontologies--ExtruOnt--ExtruOnt_type=parsed.ttl")

ontdoc = pylode.OntDoc(graph)

Which raises the error:

Traceback (most recent call last):
  File "/home/denis/workspace/Job/testarea/pylode_test/test_pylode.py", line 7, in <module>
    ontdoc = pylode.OntDoc(graph)
  File "/home/denis/workspace/Job/testarea/pylode_test/env/lib/python3.10/site-packages/pylode/ontdoc.py", line 104, in __init__
    self._ontdoc_inference(self.ont)
  File "/home/denis/workspace/Job/testarea/pylode_test/env/lib/python3.10/site-packages/pylode/ontdoc.py", line 154, in _ontdoc_inference
    for s_ in g.subjects(RDF.type, OWL.Class):
  File "/home/denis/workspace/Job/testarea/pylode_test/env/lib/python3.10/site-packages/rdflib/graph.py", line 746, in subjects
    for s, p, o in self.triples((None, predicate, object)):
AttributeError: 'URIRef' object has no attribute 'triples'

The problem was rather simple: The cast method was used in the wrong order, resulting in the wrong passed result type.

@nicholascar nicholascar merged commit a2485cb into RDFLib:master May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants