[isidorus-cvs] r111 - in trunk/src: . unit_tests xml/rdf

Author: lgiessmann Date: Fri Aug 7 11:48:40 2009 New Revision: 111 Log: finalized the unit tests for poems.rdf Modified: trunk/src/constants.lisp trunk/src/unit_tests/poems.rdf trunk/src/unit_tests/poems_light.rdf trunk/src/unit_tests/rdf_importer_test.lisp trunk/src/xml/rdf/importer.lisp trunk/src/xml/rdf/rdf_tools.lisp Modified: trunk/src/constants.lisp ============================================================================== --- trunk/src/constants.lisp (original) +++ trunk/src/constants.lisp Fri Aug 7 11:48:40 2009 @@ -37,7 +37,8 @@ :*rdf-rest* :*rdf2tm-object* :*rdf2tm-subject* - :*rdf2tm-collection*)) + :*rdf2tm-collection* + :*rdf2tm-scope-prefix*)) (in-package :constants) (defparameter *xtm2.0-ns* "http://www.topicmaps.org/xtm/") @@ -94,4 +95,6 @@ (defparameter *rdf2tm-subject* "http://isidorus/rdf2tm_mapping#subject") -(defparameter *rdf2tm-collection* "http://isidorus/rdf2tm_mapping#collection") \ No newline at end of file +(defparameter *rdf2tm-collection* "http://isidorus/rdf2tm_mapping#collection") + +(defparameter *rdf2tm-scope-prefix* "http://isidorus/rdf2tm_mapping/scope#") \ No newline at end of file Modified: trunk/src/unit_tests/poems.rdf ============================================================================== --- trunk/src/unit_tests/poems.rdf (original) +++ trunk/src/unit_tests/poems.rdf Fri Aug 7 11:48:40 2009 @@ -16,7 +16,7 @@ <types:Event> <arcs:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date">28.08.1749</arcs:date> <arcs:place> - <rdf:Description rdf:about="/region/FrankfurtMain"> + <rdf:Description rdf:about="/metropolis/FrankfurtMain"> <rdf:type> <rdf:Description rdf:about="/types/Metropolis"> <rdfs:subClassOf rdf:resource="/types/Region"/> @@ -33,7 +33,7 @@ <arcs:population rdf:datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">82099232</arcs:population> <arcs:officialese rdf:resource="language/German"/> <arcs:capital> - <rdf:Description rdf:about="http://some.where/region/Berlin"> + <rdf:Description rdf:about="http://some.where/metropolis/Berlin"> <rdf:type> <rdf:Description rdf:about="http://some.where/types/Metropolis"/> </rdf:type> @@ -54,9 +54,9 @@ <rdf:type rdf:resource="Event"/> <arcs:date rdf:datatype="#date" xml:base="http://www.w3.org/2001/XMLSchema">22.03.1832</arcs:date> <arcs:place xml:base=""> - <types:City rdf:about="Weimar" arcs:fullName="Weimar"> + <types:City rdf:about="http://some.where/city/Weimar" arcs:fullName="Weimar"> <rdfs:subClassOf rdf:resource="http://some.where/types/Region"/> - <arcs:population rdf:datatype="http://www.w3.org/2001/XMLSchema#unsigneLong">64720</arcs:population> + <arcs:population rdf:datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">64720</arcs:population> <arcs:locatedIn rdf:resource="http://some.where/country/Germany"/> </types:City> </arcs:place> Modified: trunk/src/unit_tests/poems_light.rdf ============================================================================== --- trunk/src/unit_tests/poems_light.rdf (original) +++ trunk/src/unit_tests/poems_light.rdf Fri Aug 7 11:48:40 2009 @@ -16,7 +16,7 @@ <types:Event> <arcs:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date">28.08.1749</arcs:date> <arcs:place> - <rdf:Description rdf:about="/region/FrankfurtMain"> + <rdf:Description rdf:about="/metropolis/FrankfurtMain"> <rdf:type> <rdf:Description rdf:about="/types/Metropolis"> <rdfs:subClassOf rdf:resource="/types/Region"/> @@ -33,7 +33,7 @@ <arcs:population rdf:datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">82099232</arcs:population> <arcs:officialese rdf:resource="language/German"/> <arcs:capital> - <rdf:Description rdf:about="http://some.where/region/Berlin"> + <rdf:Description rdf:about="http://some.where/metropolis/Berlin"> <rdf:type> <rdf:Description rdf:about="http://some.where/types/Metropolis"/> </rdf:type> @@ -54,9 +54,9 @@ <rdf:type rdf:resource="Event"/> <arcs:date rdf:datatype="#date" xml:base="http://www.w3.org/2001/XMLSchema">22.03.1832</arcs:date> <arcs:place xml:base=""> - <types:City rdf:about="Weimar" arcs:fullName="Weimar"> + <types:City rdf:about="http://some.where/city/Weimar" arcs:fullName="Weimar"> <rdfs:subClassOf rdf:resource="http://some.where/types/Region"/> - <arcs:population rdf:datatype="http://www.w3.org/2001/XMLSchema#unsigneLong">64720</arcs:population> + <arcs:population rdf:datatype="http://www.w3.org/2001/XMLSchema#unsignedLong">64720</arcs:population> <arcs:locatedIn rdf:resource="http://some.where/country/Germany"/> </types:City> </arcs:place> Modified: trunk/src/unit_tests/rdf_importer_test.lisp ============================================================================== --- trunk/src/unit_tests/rdf_importer_test.lisp (original) +++ trunk/src/unit_tests/rdf_importer_test.lisp Fri Aug 7 11:48:40 2009 @@ -55,7 +55,9 @@ :test-import-node-reification :test-import-dom :test-poems-rdf-occurrences - :test-poems-rdf-associations)) + :test-poems-rdf-associations + :test-poems-rdf-typing + :test-poems-rdf-topics)) (declaim (optimize (debug 3) (speed 0) (safety 3) (space 0) (compilation-speed 0))) @@ -1728,17 +1730,31 @@ (occs (elephant:get-instances-by-class 'd:OccurrenceC)) (assocs (elephant:get-instances-by-class 'd:AssociationC)) (arcs "http://some.where/relationship/") + (goethe "http://some.where/author/Goethe") + (weimar "http://some.where/city/Weimar") + (berlin "http://some.where/metropolis/Berlin") + (frankfurt "http://some.where/metropolis/FrankfurtMain") + (germany "http://some.where/country/Germany") + (zauberlehrling "http://some.where/poem/Der_Zauberlehrling") + (prometheus "http://some.where/poem/Prometheus") + (erlkoenig "http://some.where/ballad/Der_Erlkoenig") (date "http://www.w3.org/2001/XMLSchema#date") + (de (d:get-item-by-id "http://isidorus/rdf2tm_mapping/scope#de")) (long "http://www.w3.org/2001/XMLSchema#unsignedLong")) (is (= (length topics) 65)) (is (= (length occs) 23)) (is (= (length assocs) 30)) + (is-true de) (is (= (count-if #'(lambda(x) (and (= (length (d:psis (d:instance-of x))) 1) (string= (d:uri (first (d:psis (d:instance-of x)))) (concatenate 'string arcs "firstName")) - (string= *xml-string* (d:datatype x)))) + (string= *xml-string* (d:datatype x)) + (= (length (d:themes x)) 0) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + goethe))) occs) 1)) (is (= (count-if @@ -1746,7 +1762,11 @@ (and (= (length (d:psis (d:instance-of x))) 1) (string= (d:uri (first (d:psis (d:instance-of x)))) (concatenate 'string arcs "lastName")) - (string= *xml-string* (d:datatype x)))) + (string= *xml-string* (d:datatype x)) + (= (length (d:themes x)) 0) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + goethe))) occs) 1)) (is (= (count-if @@ -1754,15 +1774,61 @@ (and (= (length (d:psis (d:instance-of x))) 1) (string= (d:uri (first (d:psis (d:instance-of x)))) (concatenate 'string arcs "fullName")) - (string= *xml-string* (d:datatype x)))) + (string= *xml-string* (d:datatype x)) + (= (length (d:themes x)) 0) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + weimar))) occs) - 2)) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "fullName")) + (string= *xml-string* (d:datatype x)) + (= (length (d:themes x)) 0) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + frankfurt))) + occs) + 1)) (is (= (count-if #'(lambda(x) (and (= (length (d:psis (d:instance-of x))) 1) (string= (d:uri (first (d:psis (d:instance-of x)))) (concatenate 'string arcs "nativeName")) - (string= *xml-string* (d:datatype x)))) + (string= *xml-string* (d:datatype x)) + (= 1 (length (d:themes x))) + (eql (first (d:themes x)) de) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + germany))) + occs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "title")) + (string= *xml-string* (d:datatype x)) + (= 1 (length (d:themes x))) + (eql (first (d:themes x)) de) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + zauberlehrling))) + occs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "title")) + (= 0 (length (d:themes x))) + (string= *xml-string* (d:datatype x)) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + prometheus))) occs) 1)) (is (= (count-if @@ -1770,31 +1836,109 @@ (and (= (length (d:psis (d:instance-of x))) 1) (string= (d:uri (first (d:psis (d:instance-of x)))) (concatenate 'string arcs "title")) - (string= *xml-string* (d:datatype x)))) + (string= *xml-string* (d:datatype x)) + (= 1 (length (d:themes x))) + (eql (first (d:themes x)) de) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + erlkoenig))) + occs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "content")) + (string= *xml-string* (d:datatype x)) + (= 1 (length (d:themes x))) + (eql (first (d:themes x)) de) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + zauberlehrling))) + occs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "content")) + (string= *xml-string* (d:datatype x)) + (= 1 (length (d:themes x))) + (eql (first (d:themes x)) de) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + prometheus))) occs) - 3)) + 1)) (is (= (count-if #'(lambda(x) (and (= (length (d:psis (d:instance-of x))) 1) (string= (d:uri (first (d:psis (d:instance-of x)))) (concatenate 'string arcs "content")) - (string= *xml-string* (d:datatype x)))) + (string= *xml-string* (d:datatype x)) + (= 1 (length (d:themes x))) + (eql (first (d:themes x)) de) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + erlkoenig))) + occs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "population")) + (string= long (d:datatype x)) + (= 0 (length (d:themes x))) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + weimar))) + occs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "population")) + (string= long (d:datatype x)) + (= 0 (length (d:themes x))) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + frankfurt))) + occs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "population")) + (string= long (d:datatype x)) + (= 0 (length (d:themes x))) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + berlin))) occs) - 3)) + 1)) (is (= (count-if #'(lambda(x) (and (= (length (d:psis (d:instance-of x))) 1) (string= (d:uri (first (d:psis (d:instance-of x)))) (concatenate 'string arcs "population")) - (string= long (d:datatype x)))) + (string= long (d:datatype x)) + (= 0 (length (d:themes x))) + (= (length (d:psis (d:topic x))) 1) + (string= (d:uri (first (d:psis (d:topic x)))) + germany))) occs) - 3)) + 1)) (is (= (count-if #'(lambda(x) (and (= (length (d:psis (d:instance-of x))) 1) (string= (d:uri (first (d:psis (d:instance-of x)))) (concatenate 'string arcs "date")) - (string= date (d:datatype x)))) + (string= date (d:datatype x)) + (= 0 (length (d:themes x))) + (= (length (d:psis (d:topic x))) 0))) occs) 2)) (is (= (count-if @@ -1802,26 +1946,763 @@ (and (= (length (d:psis (d:instance-of x))) 1) (string= (d:uri (first (d:psis (d:instance-of x)))) (concatenate 'string arcs "start")) - (string= date (d:datatype x)))) + (string= date (d:datatype x)) + (= 1 (length (d:themes x))) + (eql (first (d:themes x)) de) + (= (length (d:psis (d:topic x))) 0))) + + occs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "start")) + (string= date (d:datatype x)) + (= 0 (length (d:themes x))) + (= (length (d:psis (d:topic x))) 0))) + + occs) + 2)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "end")) + (string= date (d:datatype x)) + (= 1 (length (d:themes x))) + (eql (first (d:themes x)) de) + (= (length (d:psis (d:topic x))) 0))) occs) - 3)) + 1)) (is (= (count-if #'(lambda(x) (and (= (length (d:psis (d:instance-of x))) 1) (string= (d:uri (first (d:psis (d:instance-of x)))) (concatenate 'string arcs "end")) - (string= date (d:datatype x)))) + (string= date (d:datatype x)) + (= 0 (length (d:themes x))) + (= (length (d:psis (d:topic x))) 0))) occs) - 3))))) + 2))))) (test test-poems-rdf-associations "Tests general functionality of the rdf-importer module with the file poems_light.rdf." (with-fixture rdf-test-db () + (let ((assocs (elephant:get-instances-by-class 'd:AssociationC)) + (isi-object (d:get-item-by-psi constants::*rdf2tm-object*)) + (isi-subject (d:get-item-by-psi constants::*rdf2tm-subject*)) + (arcs "http://some.where/relationship/") + (goethe "http://some.where/author/Goethe") + (germany "http://some.where/country/Germany") + (berlin "http://some.where/metropolis/Berlin") + (german "http://some.where/language/German") + (frankfurt "http://some.where/metropolis/FrankfurtMain") + (weimar "http://some.where/city/Weimar") + (zauberlehrling "http://some.where/poem/Der_Zauberlehrling") + (prometheus "http://some.where/poem/Prometheus") + (erlkoenig "http://some.where/ballad/Der_Erlkoenig")) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "born")) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + goethe))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "died")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + goethe))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "wrote")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + goethe))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "capital")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + germany))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + berlin))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "officialese")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + germany))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + german))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "place")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + frankfurt))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "place")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + weimar))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "locatedIn")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + frankfurt))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + germany))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "locatedIn")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + weimar))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + germany))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "locatedIn")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + berlin))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + germany))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "dateRange")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + prometheus))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "dateRange")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + zauberlehrling))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string arcs "dateRange")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + erlkoenig))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string constants:*rdf-ns* "_1")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + zauberlehrling))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string constants:*rdf-ns* "_1")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + erlkoenig))) + (d:roles x)))) + assocs) + 1)) + (is (= (count-if + #'(lambda(x) + (and (= (length (d:psis (d:instance-of x))) 1) + (string= (d:uri (first (d:psis (d:instance-of x)))) + (concatenate 'string constants:*rdf-ns* "_2")) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-subject) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) isi-object) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + prometheus))) + (d:roles x)))) + assocs) + 1))))) - )) +(test test-poems-rdf-typing + "Tests general functionality of the rdf-importer module with the file + poems_light.rdf." + (with-fixture rdf-test-db () + (let ((assocs (elephant:get-instances-by-class 'd:AssociationC)) + (type (get-item-by-psi constants:*type-psi*)) + (instance (get-item-by-psi constants:*instance-psi*)) + (type-instance (get-item-by-psi constants:*type-instance-psi*)) + (subtype (get-item-by-psi constants:*subtype-psi*)) + (supertype (get-item-by-psi constants:*supertype-psi*)) + (supertype-subtype + (get-item-by-psi constants:*supertype-subtype-psi*)) + (region "http://some.where/types/Region") + (metropolis "http://some.where/types/Metropolis") + (city "http://some.where/types/City") + (frankfurt "http://some.where/metropolis/FrankfurtMain") + (weimar "http://some.where/city/Weimar") + (berlin "http://some.where/metropolis/Berlin") + (language "http://some.where/types/Language") + (german "http://some.where/language/German") + (author "http://some.where/types/Author") + (goethe "http://some.where/author/Goethe") + (bag (concatenate 'string constants::*rdf-ns* "Bag")) + (poem "http://some.where/types/Poem") + (ballad "http://some.where/types/Ballad") + (zauberlehrling "http://some.where/poem/Der_Zauberlehrling") + (prometheus "http://some.where/poem/Prometheus") + (erlkoenig "http://some.where/ballad/Der_Erlkoenig") + (country "http://some.where/types/Country") + + ) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) supertype-subtype) + (= (length (d:roles x)) 2) + (= (count-if + #'(lambda(y) + (or (eql (d:instance-of y) supertype) + (eql (d:instance-of y) subtype))) + (d:roles x))))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) supertype-subtype) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) supertype) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + region))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) subtype) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + metropolis))) + (d:roles x)))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) supertype-subtype) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) supertype) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + region))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) subtype) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + city))) + (d:roles x)))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) type-instance) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) type) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + metropolis))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) instance) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + frankfurt))) + (d:roles x)))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) type-instance) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) type) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + metropolis))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) instance) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + berlin))) + (d:roles x)))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) type-instance) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) type) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + city))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) instance) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + weimar))) + (d:roles x)))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) type-instance) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) type) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + language))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) instance) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + german))) + (d:roles x)))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) type-instance) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) type) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + bag))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) instance) + (= (length (d:psis (d:player y))) 0))) + (d:roles x)))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) type-instance) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) type) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + author))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) instance) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + goethe))) + (d:roles x)))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) type-instance) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) type) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + ballad))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) instance) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + erlkoenig))) + (d:roles x)))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) type-instance) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) type) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + poem))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) instance) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + zauberlehrling))) + (d:roles x)))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) type-instance) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) type) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + poem))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) instance) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + prometheus))) + (d:roles x)))) + assocs))) + (is (= (count-if + #'(lambda(x) + (and (eql (d:instance-of x) type-instance) + (= (length (d:roles x)) 2) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) type) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + country))) + (d:roles x)) + (find-if + #'(lambda(y) + (and (eql (d:instance-of y) instance) + (= (length (d:psis (d:player y))) 1) + (string= (d:uri (first (d:psis (d:player y)))) + poem))) + (d:roles x)))) + assocs)))))) + + +(defun check-topic (top psi) + "A simple helper for test-poems-rdf-topics." + (is-true top) + (is (= (length (d:psis top)) (if psi 1 0))) + (when psi + (is (string= (d:uri (first (d:psis top))) psi))) + (is (= (length (d:names top)) 0))) + + +(test test-poems-rdf-topics + "Tests general functionality of the rdf-importer module with the file + poems_light.rdf." + (with-fixture rdf-test-db () + (let ((arcs "http://some.where/relationship/") + (types "http://some.where/types/")) + (let ((goethe (get-item-by-id "http://some.where/author/Goethe")) + (author (get-item-by-id (concatenate 'string types "Author"))) + (first-name (get-item-by-id + (concatenate 'string arcs "firstName"))) + (last-name (get-item-by-id + (concatenate 'string arcs "lastName"))) + (born (get-item-by-id (concatenate 'string arcs "born"))) + (event (get-item-by-id (concatenate 'string types "Event"))) + (date (get-item-by-id (concatenate 'string arcs "date"))) + (place (get-item-by-id (concatenate 'string arcs "place"))) + (frankfurt (get-item-by-id + "http://some.where/metropolis/FrankfurtMain")) + (metropolis (get-item-by-id (concatenate 'string types + "Metropolis"))) + (region (get-item-by-id (concatenate 'string types "Region"))) + (population (get-item-by-id (concatenate 'string arcs + "population"))) + (locatedIn (get-item-by-id (concatenate 'string arcs + "locatedIn"))) + (germany (get-item-by-id "http://some.where/country/Germany")) + (country (get-item-by-id (concatenate 'string types "Country"))) + (native-name (get-item-by-id (concatenate 'string arcs + "nativeName"))) + (officialese (get-item-by-id (concatenate 'string arcs + "officialese"))) + (german (get-item-by-id "http://some.where/language/German")) + (capital (get-item-by-id (concatenate 'string arcs "capital"))) + (berlin (get-item-by-id "http://some.where/metropolis/Berlin")) + (died (get-item-by-id (concatenate 'string arcs "died"))) + (weimar (get-item-by-id "http://some.where/city/Weimar")) + (city (get-item-by-id (concatenate 'string types "City"))) + (wrote (get-item-by-id (concatenate 'string arcs "wrote"))) + (goethe-literature (get-item-by-id "goethe_literature")) + (bag (get-item-by-id (concatenate 'string *rdf-ns* "Bag"))) + (_1 (get-item-by-id (concatenate 'string *rdf-ns* "_1"))) + (_2 (get-item-by-id (concatenate 'string *rdf-ns* "_2"))) + (zauberlehrling + (get-item-by-id "http://some.where/poem/Der_Zauberlehrling")) + (poem (get-item-by-id (concatenate 'string types "Poem"))) + (dateRange (get-item-by-id (concatenate 'string arcs "dateRange"))) + (start (get-item-by-id (concatenate 'string arcs "start"))) + (end (get-item-by-id (concatenate 'string arcs "end"))) + (title (get-item-by-id (concatenate 'string arcs "title"))) + (content (get-item-by-id (concatenate 'string arcs "content"))) + (erlkoenig (get-item-by-id "http://some.where/ballad/Der_Erlkoenig")) + (ballad (get-item-by-id (concatenate 'string types "Ballad"))) + (de (get-item-by-id (concatenate + 'string constants::*rdf2tm-scope-prefix* + "de"))) + (prometheus (get-item-by-id "http://some.where/poem/Prometheus")) + (language (get-item-by-id (concatenate 'string types "Language"))) + (full-name (get-item-by-id (concatenate 'string arcs "fullName")))) + (check-topic goethe "http://some.where/author/Goethe") + (check-topic author (concatenate 'string types "Author")) + (check-topic first-name (concatenate 'string arcs "firstName")) + (check-topic last-name (concatenate 'string arcs "lastName")) + (check-topic born (concatenate 'string arcs "born")) + (check-topic event (concatenate 'string types "Event")) + (check-topic date (concatenate 'string arcs "date")) + (check-topic place (concatenate 'string arcs "place")) + (check-topic frankfurt "http://some.where/metropolis/FrankfurtMain") + (check-topic metropolis (concatenate 'string types "Metropolis")) + (check-topic region (concatenate 'string types "Region")) + (check-topic population (concatenate 'string arcs "population")) + (check-topic locatedIn (concatenate 'string arcs "locatedIn")) + (check-topic germany "http://some.where/country/Germany") + (check-topic country (concatenate 'string types "Country")) + (check-topic native-name (concatenate 'string arcs "nativeName")) + (check-topic officialese (concatenate 'string arcs "officialese")) + (check-topic german "http://some.where/language/German") + (check-topic capital (concatenate 'string arcs "capital")) + (check-topic berlin "http://some.where/metropolis/Berlin") + (check-topic died (concatenate 'string arcs "died")) + (check-topic weimar "http://some.where/city/Weimar") + (check-topic city (concatenate 'string types "City")) + (check-topic wrote (concatenate 'string arcs "wrote")) + (check-topic goethe-literature nil) + (check-topic bag (concatenate 'string *rdf-ns* "Bag")) + (check-topic _1 (concatenate 'string *rdf-ns* "_1")) + (check-topic _2 (concatenate 'string *rdf-ns* "_2")) + (check-topic zauberlehrling "http://some.where/poem/Der_Zauberlehrling") + (check-topic poem (concatenate 'string types "Poem")) + (check-topic dateRange (concatenate 'string arcs "dateRange")) + (check-topic start (concatenate 'string arcs "start")) + (check-topic end (concatenate 'string arcs "end")) + (check-topic title (concatenate 'string arcs "title")) + (check-topic content (concatenate 'string arcs "content")) + (check-topic erlkoenig "http://some.where/ballad/Der_Erlkoenig") + (check-topic ballad (concatenate 'string types "Ballad")) + (check-topic de (concatenate 'string constants::*rdf2tm-scope-prefix* + "de")) + (check-topic prometheus "http://some.where/poem/Prometheus") + (check-topic language (concatenate 'string types "Language")) + (check-topic full-name (concatenate 'string arcs "fullName")) + (is (= (count-if #'(lambda(x) + (null (d:psis x))) + (elephant:get-instances-by-class 'd:TopicC)) + 6)))))) (defun run-rdf-importer-tests() @@ -1840,4 +2721,6 @@ (it.bese.fiveam:run! 'test-import-node-reification) (it.bese.fiveam:run! 'test-import-dom) (it.bese.fiveam:run! 'test-poems-rdf-occurrences) - (it.bese.fiveam:run! 'test-poems-rdf-associations)) \ No newline at end of file + (it.bese.fiveam:run! 'test-poems-rdf-associations) + (it.bese.fiveam:run! 'test-poems-rdf-typing) + (it.bese.fiveam:run! 'test-poems-rdf-topics)) \ No newline at end of file Modified: trunk/src/xml/rdf/importer.lisp ============================================================================== --- trunk/src/xml/rdf/importer.lisp (original) +++ trunk/src/xml/rdf/importer.lisp Fri Aug 7 11:48:40 2009 @@ -23,8 +23,8 @@ (get-store-spec repository-path))) (xml-importer:init-isidorus) (init-rdf-module) - (rdf-importer rdf-xml-path repository-path :tm-id tm-id) - :document-id document-id + (rdf-importer rdf-xml-path repository-path :tm-id tm-id + :document-id document-id) (when elephant:*store-controller* (elephant:close-store))) @@ -409,15 +409,13 @@ topic-id err))))))))) -(defun make-lang-topic (lang tm-id start-revision tm +(defun make-lang-topic (lang start-revision tm &key (document-id *document-id*)) "Returns a topic with the topicid tm-id/lang. If no such topic exist there will be created one." - (declare (TopicMapC tm)) - (when (and lang tm-id) - (tm-id-p tm-id "make-lang-topic") + (when lang (let ((psi-and-topic-id - (absolutize-value lang nil tm-id))) + (concatenate-uri *rdf2tm-scope-prefix* lang))) (let ((top (get-item-by-id psi-and-topic-id :xtm-id document-id :revision start-revision))) (if top @@ -538,7 +536,7 @@ (let ((type-top (make-topic-stub type nil nil nil start-revision xml-importer::tm :document-id document-id)) - (lang-top (make-lang-topic lang tm-id start-revision + (lang-top (make-lang-topic lang start-revision xml-importer::tm :document-id document-id))) (let ((occurrence Modified: trunk/src/xml/rdf/rdf_tools.lisp ============================================================================== --- trunk/src/xml/rdf/rdf_tools.lisp (original) +++ trunk/src/xml/rdf/rdf_tools.lisp Fri Aug 7 11:48:40 2009 @@ -31,7 +31,8 @@ *rdf-nil* *rdf-first* *rdf-rest* - *rdf2tm-collection*) + *rdf2tm-collection* + *rdf2tm-scope-prefix*) (:import-from :xml-constants *rdf_core_psis.xtm*) (:import-from :xml-constants
participants (1)
-
Lukas Giessmann