This post was updated on .
Hello guys, I have a problem and I’d like to have a suggestion from you if it’s possible. The code is:
with onto: class Animal(Thing): pass class Person(Thing): pass my_pet = Animal("my_dog") my_person = Person("Tom") pets = types.new_class("mini_pets", (ObjectProperty,)) Then I don't manage to use the object relation dynamically: my_pet.pets = [my_person] OR my_pet.pets.append(my_person) With .append I have an error while with the code my_pet.pets = [my_person] I don't have an error but It doesn't work. How can I do? Best regards, Thanks to all in advance. Sorry for my English a little low... |
Administrator
|
Hi,
You need to create your object property as follows : with onto: pets = types.new_class("pets", (ObjectProperty,)) The object property must be created inside an ontology, and its name should be the same as the name of the Python attribute (you can use pets.python_name to specify another name if needed). Best regards, Jiba |
This post was updated on .
Hi Jiba,
object_property_list=['Build_NoBelongsToModule', 'Begin_DelimiterBelongsToModule', 'Tracking_NotedependsonFailure_Snippet', 'Test_Step_DescBelongsToModule', 'Tracking_NotedependsonModule', 'Failure_SnippetBelongsToModule', 'Tracking_NoteBelongsToModule', 'SuiteBelongsToModule', 'PlatformBelongsToModule', 'Failed_Teststep_NoBelongsToModule'] domain_list=['Build_No', 'Begin_Delimiter', 'Tracking_Note', 'Test_Step_Desc', 'Tracking_Note', 'Failure_Snippet', 'Tracking_Note', 'Suite', 'Platform', 'Failed_Teststep_No'] range_list=['Module', 'Module', 'Failure_Snippet', 'Module', 'Module', 'Module', 'Module', 'Module', 'Module', 'Module'] from the above lists, I am creating object properties and assigning the values from csv files. I have already created the instances for each of the values from below list ['Module', 'Begin_Delimiter', 'Platform', 'Suite', 'Build_No', 'Failed_Teststep_No', 'Test_Step_Desc', 'Failure_Snippet', 'Tracking_Note'] for op,domain,r in zip(object_property_list,domain_list,range_list): object_property=type(op, (ObjectProperty,), {"domain": [onto_final[domain]], "range": [onto_final[r]]}) object_property.python_name ="oproperty" for d,y in zip(onto_final[domain].instances(),onto_final[r].instances()): d.oproperty.append(y) But instead of giving results like <Tracking_Note rdf:about="#tracking_note1"> <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/> <TrackingNoteBelongsToModule rdf:resource="#module1"/> <TrackingNotedependsonModule rdf:resource="#module1"/> <TrackingNotedependsonfailure_Snippet rdf:resource="#Failure_Snippet1/> </Tracking_Note> It is giving result like: <Tracking_Note rdf:about="#tracking_note1"> <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/> <Tracking_NoteBelongsToModule rdf:resource="#module1"/> <Tracking_NoteBelongsToModule rdf:resource="#failure_snippet1"/> <hasTracking_Note rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Rerun candidate</hasTracking_Note> </Tracking_Note> what is causing the issue that instead of getting different values for different object properties ,it is taking different values for same object properties,I am unable to figure out. |
Free forum by Nabble | Edit this page |