amalgame/commit

ADDED: basic selecter mode for preload

authorJacco van Ossenbruggen
Sun Aug 31 12:02:50 2014 +0200
committerJacco van Ossenbruggen
Sun Aug 31 12:02:50 2014 +0200
commit8754615a684ae5d9e9c728c75009c08a149d3736
tree7ced5d08b716d3803eab66440b58b0b485f93ed4
parentd38c3eb54b339c94c060cb2097674e04ceff4606
Diff style: patch stat
diff --git a/config-available/ag_modules.pl b/config-available/ag_modules.pl
index 93ef516..82542b2 100644
--- a/config-available/ag_modules.pl
+++ b/config-available/ag_modules.pl
@@ -23,6 +23,7 @@
 :- use_module(library(ag_modules/descendent_selecter)).
 :- use_module(library(ag_modules/related_selecter)).
 :- use_module(library(ag_modules/sibling_selecter)).
+:- use_module(library(ag_modules/preloaded_selecter)).
 
 % Vocabulary filters/selecters
 :- use_module(library(ag_modules/voc_exclude)).
diff --git a/lib/ag_modules/preloaded_selecter.pl b/lib/ag_modules/preloaded_selecter.pl
new file mode 100644
index 0000000..ae4cd76
--- /dev/null
+++ b/lib/ag_modules/preloaded_selecter.pl
@@ -0,0 +1,38 @@
+:- module(preloaded_selecter,[]).
+
+:- use_module(library(semweb/rdf_db)).
+:- use_module(library(semweb/rdfs)).
+:- use_module(library(amalgame/map)).
+
+:- public amalgame_module/1.
+:- public selecter/5.
+:- public parameter/4.
+
+amalgame_module(amalgame:'SelectPreLoadedSelecter').
+
+parameter(name, oneof(Loaded), 'no default',
+	  'url of named mapping graph') :-
+	findall(M,
+		(   rdfs_individual_of(M, amalgame:'LoadedMapping'),
+		    rdf_graph(M),
+		    rdf_graph_property(M, triples(N)),
+		    N > 0
+		), Loaded).
+
+selecter(In, Sel, Dis, [], Options) :-
+	option(name(Graph), Options),
+	selecter_(Graph, In, Sel, Dis).
+
+selecter_(_Graph, [], [], []).
+selecter_(Graph, [Hin|Tin], Sel, Dis) :-
+	Hin = align(S,T,P),
+	(   has_correspondence(align(S, T, PGraph), Graph)
+	->  append(PGraph, P, Pmerged),
+	    Sel = [ align(S, T, Pmerged) | Tsel],
+	    Dis = Tdis
+	;   Sel = Tsel,
+	    Dis = [ align(S,T,P) | Tdis]
+	),
+	selecter_(Graph, Tin, Tsel, Tdis).
+
+
diff --git a/rdf/tool/ag_modules.ttl b/rdf/tool/ag_modules.ttl
index c1a8da2..dd1aae8 100644
--- a/rdf/tool/ag_modules.ttl
+++ b/rdf/tool/ag_modules.ttl
@@ -13,6 +13,11 @@ amalgame:SelectPreLoaded
     skos:definition "Match mappings from preloaded named graph against concepts in source and target vocabularies"@en ;
     rdfs:subClassOf amalgame:Matcher .
 
+amalgame:SelectPreLoadedSelecter
+    rdfs:label "import/preloaded"@en ;
+    skos:definition "Select mappings with corresponding mappings in the preloaded mapping, discard others with the same source/target."@en ;
+    rdfs:subClassOf amalgame:MappingSelecter .
+
 amalgame:ExactLabelMatcher
     rdfs:label "string/label (exact)"@en ;
     skos:definition "A basic label matcher based on exact matching labels of source and target concepts"@en ;