[isidorus-cvs] r428 - in trunk/src: TM-SPARQL unit_tests
Lukas Giessmann
lgiessmann at common-lisp.net
Tue Apr 26 13:36:47 UTC 2011
Author: lgiessmann
Date: Tue Apr 26 09:36:46 2011
New Revision: 428
Log:
TM-SPARQL: added the possibility to search for triplles of the form "?var1 ?var2 ?var3" => adopted the corresponding unit-tests to this change
Modified:
trunk/src/TM-SPARQL/sparql.lisp
trunk/src/unit_tests/sparql_test.lisp
Modified: trunk/src/TM-SPARQL/sparql.lisp
==============================================================================
--- trunk/src/TM-SPARQL/sparql.lisp (original)
+++ trunk/src/TM-SPARQL/sparql.lisp Tue Apr 26 09:36:46 2011
@@ -572,7 +572,8 @@
(let ((results (append
(or (filter-by-given-subject construct :revision revision)
(filter-by-given-predicate construct :revision revision)
- (filter-by-given-object construct :revision revision))
+ (filter-by-given-object construct :revision revision)
+ (filter-by-variable-triple construct :revision revision))
(filter-by-special-uris construct :revision revision))))
(map 'list #'(lambda(result)
(push (getf result :subject) (subject-result construct))
@@ -583,6 +584,29 @@
results)))))
+(defgeneric filter-by-variable-triple (construct &key revision)
+ (:documentation "Returns all graphs that match a triple consisting
+ only of variables.")
+ (:method ((construct SPARQL-Triple) &key (revision *TM-REVISION*))
+ (when (and (variable-p (subject construct))
+ (variable-p (predicate construct))
+ (variable-p (object construct)))
+ (let ((all-possible-subjects
+ (append (get-all-topics revision)
+ (get-all-occurrences revision)
+ (get-all-names revision)
+ (get-all-variants revision)
+ (get-all-associations revision)
+ (get-all-roles revision))))
+ (remove-null
+ (loop for subj in all-possible-subjects
+ append (when (typep subj 'TopicC)
+ (append (filter-characteristics
+ subj nil nil nil :revision revision)
+ (filter-associations
+ subj nil nil :revision revision)))))))))
+
+
(defgeneric filter-by-given-object (construct &key revision)
(:documentation "Returns a list representing a triple that is the result
of a given object.")
Modified: trunk/src/unit_tests/sparql_test.lisp
==============================================================================
--- trunk/src/unit_tests/sparql_test.lisp (original)
+++ trunk/src/unit_tests/sparql_test.lisp Tue Apr 26 09:36:46 2011
@@ -450,11 +450,11 @@
(is (= (length (tm-sparql::select-group q-obj-2)) 1))
(is-true q-obj-3)
(is (= (length (tm-sparql::select-group q-obj-3)) 1))
- (is-false (tm-sparql::subject-result
+ (is-true (tm-sparql::subject-result
(first (tm-sparql::select-group q-obj-1))))
- (is-false (tm-sparql::predicate-result
+ (is-true (tm-sparql::predicate-result
(first (tm-sparql::select-group q-obj-1))))
- (is-false (tm-sparql::object-result
+ (is-true (tm-sparql::object-result
(first (tm-sparql::select-group q-obj-1))))
(is (= (length (tm-sparql::subject-result
(first (tm-sparql::select-group q-obj-2)))) 2))
More information about the Isidorus-cvs
mailing list