cluster_search/commit

Translate annotation structure into dc:subject.

authorChris Dijkshoorn
Tue Sep 16 15:29:41 2014 +0200
committerChris Dijkshoorn
Tue Sep 16 15:29:41 2014 +0200
commitebe5670b57bc0e79f1baaae1e3ba5c2d0cefec74
treea91af778785314c5e4ecf0a19768e58bbf95ab3d
parentc9e9c22d195b67974f605d8bbb6e6ee0bceb4331
Diff style: patch stat
diff --git a/lib/cluster_search/rdf_backward_search.pl b/lib/cluster_search/rdf_backward_search.pl
index c3e747d..562047c 100644
--- a/lib/cluster_search/rdf_backward_search.pl
+++ b/lib/cluster_search/rdf_backward_search.pl
@@ -22,6 +22,8 @@
 :- meta_predicate
 	rdf_backward_search(+, 1, -, +).
 
+:- rdf_register_prefix(aat, 'http://vocab.getty.edu/aat/').
+
 %%	rdf_backward_search(+Keyword, :TargetCond, -State, +Options)
 %
 %       Initiate a graph search by traversing resources in backwards fashion,
@@ -63,7 +65,8 @@ debug_property(graph_size(_)).
 
 %%	edge(+Node, +Score, -Link) is nondet.
 %
-%	Generate links from Node.
+%	Generate links from Object Node, consisting of a Subject,
+%	Predicate and Weight.
 
 edge(O, _, i(S,P,W)) :-
 	edge(O, S, P, W),
@@ -79,8 +82,23 @@ edge(O, S, P, W) :-
 	    subject_weight(S, Len, W)
 	).
 
+
+%%	i_edge(+O, -S, -P)
+%
+%	Find Subject that is connected through Predicate.
+
+% annotation edge hack: translate the connection between object and
+% subject through an annotation into a dc:subject predicate.
+i_edge(O, S, P) :-
+	rdf(Annotation, oa:hasBody, O),
+        rdf(Annotation, oa:hasTarget, S),
+	rdf_equal(P, dc:subject).
+
+
 i_edge(O, S, P) :-
-	rdf(S, P, O).
+	rdf(S, P, O),
+	% ignore annotations connected by hasTarget
+	\+ rdf_equal(S, oa:hasTarget).
 i_edge(O, S, P) :-
 	rdf(O, P0, S),
 	atom(S),
@@ -88,7 +106,9 @@ i_edge(O, S, P) :-
 	->  true
 	;   predicate_weight(P0, 1)
 	->  P = P0
-	).
+	),
+	% ignore annotations connected by hasTarget
+	\+ rdf_equal(S, oa:hasTarget).
 
 %%	predicate_weight(+Predicate, -Weight) is semidet.
 %
@@ -101,7 +121,6 @@ i_edge(O, S, P) :-
 %	Note that rdfs:comment is not searched as  it   is  supposed to
 %	be comment about the graph, and not part of the graph itself.
 
-
 predicate_weight(P, Weight) :-
 	catch(cluster_search:predicate_weight(P, Weight), _, fail), !.