Please feel free to indicate that DynaLearn is using Thea. :)
I wanted to start importing OWL files from DynaLearn, but noticed that
OWL files do not load. I'm unsure whether this is because of me
running the latest master branch merged with the axiomannotation
branch, the newer versions of Prolog or for another reason. I've just
tried loading one of the Thea test files, but it says it contains 0
triples.
1 ?- load_axioms('libraries/thea2/testfiles/music_ontology.owl', owl).
% Parsed "music_ontology.owl" in 0.06 sec; 0 triples
true.
Finally, I've written the function below to generate rdf:Lists.
Perhaps it is nice to have in Thea in some form.
Best regards,
Jochem
list_assertion([Head|Tail], Resource) :-
% There should be at least one resource in the list
\+ [Head|Tail] = [],
(
% If you want to have a list as a blank node
var(Resource) ->
rdf_bnode(ListElement),
Resource = ListElement
;
% If you want to have a specified URI for the list
ListElement = Resource
),
assert_axiom( propertyAssertion('rdf:type', ListElement, 'rdf:List') ),
assert_axiom( propertyAssertion('rdf:first', ListElement, Head) ),
list_assertion2(Tail, ListElement).
list_assertion2([], LastElement) :-
assert_axiom( propertyAssertion('rdf:rest', LastElement, 'rdf:nil') ).
list_assertion2([Head|Tail], PreviousElement) :-
% Create a new list element
rdf_bnode(ListElement),
assert_axiom( propertyAssertion('rdf:type', ListElement, 'rdf:List') ),
assert_axiom( propertyAssertion('rdf:first', ListElement, Head) ),
% Connect to the rest of the list
assert_axiom( propertyAssertion('rdf:rest', PreviousElement, ListElement) ),
list_assertion2(Tail, ListElement).
:-
rdf_register_ns(qrm, 'http://www.dynalearn.eu/models/ExampleModel.owl#'),
% List as a blank node:
list_assertion(['qrm:value1','qrm:value2','qrm:value3'],
BlankNode), % 'qrm:QuantitySpace'
assert_axiom( namedIndividual('qrm:Quantity1') ),
assert_axiom( namedIndividual('qrm:QuantitySpace1') ),
assert_axiom( propertyAssertion('qrm:hasValueList',
'qrm:QuantitySpace1', BlankNode) ),
assert_axiom( propertyAssertion('qrm:hasQuantitySpace',
'qrm:Quantity1', 'qrm:QuantitySpace1') ),
% List as a resource
assert_axiom( namedIndividual('qrm:Quantity2') ),
assert_axiom( namedIndividual('qrm:QuantitySpace2') ),
list_assertion(['qrm:value1','qrm:value2','qrm:value3'],
'qrm:QuantitySpace2'), % 'qrm:QuantitySpace'
assert_axiom( propertyAssertion('qrm:hasQuantitySpace',
'qrm:Quantity2', 'qrm:QuantitySpace2') ),
save_axioms( 'theatest.owl', owl ),
retract_all_axioms,
load_axioms('theatest.owl', owl ).
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Jochem Liem, MSc.
Informatics Institute
Faculty of Science
University of Amsterdam
http://www.science.uva.nl/~jliem/
Phone: +31 (0)20 525 6801
Mobile: +31 (0)6 4321 9992
Fax: +31 (0)20 525 7490
Visitor address:
Science Park 904, C2.248
1098 XH Amsterdam
Mailing address:
Postbus 94323
1090 GH Amsterdam
The Netherlands
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
I was wrong about the loading of the files, they seem to load
perfectly. It is just the feedback that gave me the wrong impression.
I've been playing with the List representation, but think that the
current approach might result in properties being lost in the loading
process. Furthermore, there seems to be a mismatch between how the
List representation is loaded and how it can be saved.
When loading a rdf:List, Thea now automatically converts it to a
Prolog list. However, it is valid for a rdf:List to have annotations
(rdfs:label/rdfs:comment) or be a named resource. Because the list is
automatically converted, such information does not appear in the Thea
abstract syntax. Furthermore, although an RDF list becomes a list
during the loading of an OWL file, it is invalid to assert it as a
prolog list.
I've been looking at the OWL specification, and it seems that rdf:List
does not have an abstract syntax rendering [1] (nor could I find one
for OWL2). Only the rendition to triples seems specified. Perhaps it
is better to take this approach and have helper functions to assert
rdf lists as prolog lists, or convert rdf lists to prolog. The
attached prolog file has exactly those functions, and also shows how
certain properties are lost when the resulting OWL file is loaded.
For my use cases it would be better if Thea would not do the automatic
conversion.
Thanks for you time.
Best regards,
Jochem
[1] http://www.w3.org/TR/owl-semantics/semantics-all.html#index
The label is not lost. It is just that a resource has both the
rendering as a prolog list and as a URI. For querying purposes, this
seems suboptimal. In the triples below the prolog list and the
QuantitySpace2 are the same resource. As such, I still think that
rendering the rdf:List as a triples is the best solution.
Best regards,
Jochem
Triple: http://www.dynalearn.eu/models/ExampleModel.owl#hasQuantitySpace
http://www.dynalearn.eu/models/ExampleModel.owl#Quantity2
[http://www.dynalearn.eu/models/ExampleModel.owl#value4,http://www.dynalearn.eu/models/ExampleModel.owl#value5,http://www.dynalearn.eu/models/ExampleModel.owl#value6]
Triple: http://www.w3.org/2000/01/rdf-schema#label
http://www.dynalearn.eu/models/ExampleModel.owl#QuantitySpace2
literal(This label is lost)