Bonjour Mr. Lamy,
I was already able to create the full structure of my ontology from scratch entirely using owlready, and even import the converted data! It saved me hours of work... Incredible tool! One thing I was not able to do was write the rdfs:comment (on the Data Properties). I have tryied both: Drug.comment = ["A first comment on the Drug class", "A second comment"]
(actually I had to use onto.Drug.comment, otherwise it returns that 'name is not defined'. This happens with most of the examples in the documentation)
|
I just found out myself one thing I was doing wrong: I forgot to add the main class on the dot notation: "onto.mainclass.mydataproperty" (my data property has the mainclass in the first segment of its name, and that caused me the mistake).
But that raised another problem: When I try... onto.mainclass.mydataproperty.comment = ['something']it complaints that...AttributeError: 'comment' is not a language code (must be 2-char string)!I have faced it when I was creating my data loading module, and managed to handle it. I had to use... getattr(obj, attrib).en = dataAnd it worked well! But the 'comment' property (on my data properties) did not. I can try.... onto.mainclass.mydataproperty.comment.en = ['something']But it still says...AttributeError: 'comment' is not a language code (must be 2-char string)! |
Administrator
|
Hello,
I don't understand on what you are adding an annotation. For annotating a class, the syntax is : onto.className.comment = "Your comment" For annotating a property, the syntax is : onto.propertyName.comment = "Your comment" For annotating a relation triple, for example on the triple (individual, property, value), you cannot use the 'dot' syntax. The syntax is : comment[onto.individual, onto.property, value] = "Your comment" In OWL, a class cannot have property value. Owlready accept "class attributes" (e.g. onto.className.propertyName = ...) and actually transforms them automatically in OWL restrictions (this is an advanced feature that I still need to document). I think that the restriction cannot be annotated (Protégé does not allow that). However, you can annotate the subclass-of relation between the class and the restriction. Subclass-of relations can be annotated using the same syntax than above for relations: comment[onto.className, rdfs_subclassof, superclass] = "Your comment" The difficulty is to find the appropriate restriction superclass. Just after doing onto.className.propertyName = ..., the restriction is added at the end of onto.className.is_a, so you can do it as follows: comment[onto.className, rdfs_subclassof, onto.className.is_a[-1]] = "Your comment" Best regards, Jean-Baptiste Lamy MCF, LIMICS, Université Paris 13 > I just found out myself what was wrong, I forgot to add the main class on the > dot notation: "onto.mainclass.mydataproperty" (my data property has the > mainclass in the first segment of its name, what caused me the confusion). > > But that raised another problem: > > When I try... > onto.mainclass.mydataproperty.comment = ['something'] > > it complaints that... > AttributeError: 'comment' is not a language code (must be 2-char string)! > > > I have faced it when I was creating my data loading module, and managed to > handle it. I had to use... > getattr(obj, attrib).en = data > > > And it worked well! But the 'comment' property (on my data properties) did > not. I can try.... > onto.mainclass.mydataproperty.comment.en = ['something'] > > But it still says... > AttributeError: 'comment' is not a language code (must be 2-char string)! > > > > > _______________________________________________ > If you reply to this email, your message will be added to the discussion below: > http://owlready.8326.n8.nabble.com/Annotations-not-being-saved-tp62p63.html > To start a new topic under Owlready, email [hidden email] > To unsubscribe from Owlready, visit |
Bonjour Mr. Lamy,
I am trying to annotate a property (Protégé calls it Data Property) using: onto.propertyName.comment = "Your comment" But it says: AttributeError: 'comment' is not a language code (must be 2-char string)! |
This post was updated on .
Sorry, it worked with:
onto.propertyName.comment.en = "Your comment" (I was probably too sleepy last work night) It also works dinamically with: getattr(onto, prop_name).comment.en = data Merci! Salutations, Guilherme Baesso |
Administrator
|
OK, it's more clear to me now.
You are right, onto.propertyName.comment does not work while onto.className.comment works... I'm going to investigate the problem. Kind regards, Jean-Baptiste Lamy MCF, LIMICS, Université Paris 13 > Sorry, it worked with: > > onto.propertyName.comment.en = "Your comment" > > Probably I was too sleepy last work night.... > > > > _______________________________________________ > If you reply to this email, your message will be added to the discussion below: > http://owlready.8326.n8.nabble.com/Annotations-not-being-saved-tp62p66.html > To start a new topic under Owlready, email [hidden email] > To unsubscribe from Owlready, visit |
Free forum by Nabble | Edit this page |