nie-ine / knora-utilities

a toolset for Knora
GNU General Public License v3.0
3 stars 0 forks source link

Fehlermeldung beim Import einer generierten Python Klasse (Literatur / Poem) #1

Open janCstoffregen opened 6 years ago

janCstoffregen commented 6 years ago

Version: https://github.com/nie-ine/Quick-Installation-Guide---Knora-Salsah-Sipi-GraphDB/tree/master/PrebuiltImages/20171231

Folgende Imports funktionieren nicht, nachdem die Klassen mit ttl2py erstellt worden sind:

$ python3
>> from ontologies.literature.classes.Poem import Poem
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/retobaumgartner/Projects/avp_parse copy/ontologies/literature/classes/Poem.py", line 5, in <module>
from ..properties.hasPoetry import HasPoetry
ModuleNotFoundError: No module named 'ontologies.literature.properties.hasPoetry'

@rfbaumgartner als Ansprechpartner

sacha-alex commented 6 years ago

It seems to be a bug in the ontologies you are using. The file literature-ontology-knora.ttl in Ontologies (91dffaa4acc0725b86c84bff2e346f28ea9d1839) defines the litera:Poem-Resource by using the non-existing properties litera:hasPoetry and litera:hasPoetryValue

litera:Poem
a owl:Class;
rdfs:label "poem"@en, "Gedicht"@de;
rdfs:comment """Poetic expression."""@en, """Poetische Expression."""@de;
rdfs:subClassOf litera:Expression, [
    a owl:Restriction; owl:onProperty litera:hasGenre; owl:allValuesFrom litera:Poetry], [
    a owl:Restriction; owl:onProperty litera:hasPoetry; owl:minCardinality "0"^^xsd:nonNegativeInteger], [
    a owl:Restriction; owl:onProperty litera:hasPoetryValue; owl:minCardinality "0"^^xsd:nonNegativeInteger].

Since there are no existency-checks in ttl2py, the scripts takes property's resources into account and 'assumes' that they are or will be defined in a proper way. In this case we try to use the property 'hasPoetry', since it is used in the resource (-> from ... import HasProperty), but this property was actually never created, due the lack of its definition in the .ttl-file.

hanscools commented 6 years ago

That property def. has been added some time ago. To make the old version of 20171231work the following has to be added:


litera:hasPoetry
    a owl:ObjectProperty;
    rdfs:label "has poetry"@en, "hat Poetik"@de;
    rdfs:comment """Relating a poem to poetry it has."""@en;
    rdfs:domain litera:Poem;
    rdfs:range litera:Poetry;
    rdfs:subPropertyOf litera:hasGenre;
    knora-base:subjectClassConstraint litera:Poem;
    knora-base:objectClassConstraint litera:Poetry.

litera:hasPoetryValue
    a owl:ObjectProperty;
    rdfs:label "has poetry - statement"@en, "hat Poetik - Festlegung"@de;
    rdfs:comment """Relating a poem to a reification statement of the relation between the poem and poetry it has."""@en;
    rdfs:subPropertyOf litera:hasGenreValue;
    knora-base:subjectClassConstraint litera:Poem;
    knora-base:objectClassConstraint knora-base:LinkValue.

But we are using now version 20180424, not?