amalgame/commit

CHANGED: expand vocabs as assocs

authorJacco van Ossenbruggen
Tue Sep 16 22:40:48 2014 +0200
committerJacco van Ossenbruggen
Tue Sep 16 22:40:48 2014 +0200
commit5bf3a5af759c5cda7597d6a849c74c2133727779
tree1d2f6bb22a2aca61845a63faff9dc75d45a83472
parent3abaa70a87bd0473dd5aae6470f00c6f4321bead
Diff style: patch stat
diff --git a/lib/ag_drivers/exec_amalgame_process.pl b/lib/ag_drivers/exec_amalgame_process.pl
index d836aff..d9c7320 100644
--- a/lib/ag_drivers/exec_amalgame_process.pl
+++ b/lib/ag_drivers/exec_amalgame_process.pl
@@ -110,7 +110,7 @@ exec_amalgame_process(Type, Process, Strategy, Module, MapSpec, Time, Options) :
 	rdf(Process, amalgame:source, Source, Strategy),
 	rdf(Process, amalgame:target, Target, Strategy),
 	expand_node(Strategy, Source, SourceSpec),
-	vocab_spec(Strategy, Target, TargetSpec),
+	expand_node(Strategy, Target, TargetSpec),
 	timed_call(Module:matcher(SourceSpec, TargetSpec, Mapping0,
 				  [snd_input(SecInput)|Options]), Time),
 	merge_provenance(Mapping0, Mapping),
diff --git a/lib/ag_modules/exact_label_generator.pl b/lib/ag_modules/exact_label_generator.pl
index 4091797..9f28700 100644
--- a/lib/ag_modules/exact_label_generator.pl
+++ b/lib/ag_modules/exact_label_generator.pl
@@ -39,9 +39,9 @@ parameter(match_qualified_only, boolean, false,
 %	and Target.
 
 matcher(Source, Target, Mappings, Options) :-
-	profile(findall(M, align(Source, Target, M, Options), Mappings0)),
+	findall(M, align(Source, Target, M, Options), Mappings0),
 	sort(Mappings0, Mappings).
 
 align(Source, Target, Match, Options) :-
-	member(S, Source),
+	vocab_member(S, Source),
 	exact_label_match(align(S,_,[]), Match, [target_scheme(Target)|Options]).
diff --git a/lib/amalgame/expand_graph.pl b/lib/amalgame/expand_graph.pl
index e14142d..3a9b24d 100644
--- a/lib/amalgame/expand_graph.pl
+++ b/lib/amalgame/expand_graph.pl
@@ -7,6 +7,7 @@
 	  ]).
 
 :- use_module(library(apply)).
+:- use_module(library(assoc)).
 :- use_module(library(debug)).
 :- use_module(library(lists)).
 :- use_module(library(semweb/rdf_db)).
@@ -85,7 +86,7 @@ all_mapped(Strategy, Type, Mappings, Concepts) :-
 	;   maplist(expand_node(Strategy), Mappings, Results),
 	    append(Results, Result),
 	    maplist(my_correspondence_element(Type), Result, Concepts0),
-	    ord_list_to_rbtree(Concepts0, Concepts),
+	    ord_list_to_assoc(Concepts0, Concepts),
 	    cache_mapped_concepts(Strategy, Type, Mappings, Concepts)
 	).
 
@@ -186,10 +187,12 @@ expand_vocab(Strategy, Id, Concepts) :-
 %	rdfs_individual_of(Vocab, amalgame:'Alignable'),
 %	!.
 
-expand_vocab(Strategy, Vocab, List) :-
-	findall(C, skos_in_scheme(Vocab, C), List),
+expand_vocab(Strategy, Vocab, Assoc) :-
+	findall(C-t, skos_in_scheme(Vocab, C), Pairs),
 	debug(ag_expand, 'Concepts of ~p computed and cached', [Vocab]),
-	cache_result(_, Vocab, Strategy, List).
+	sort(Pairs, Sorted),
+	ord_list_to_assoc(Sorted,Assoc),
+	cache_result(_, Vocab, Strategy, Assoc).
 
 vocab_spec(Strategy, Id, Spec) :-
 	rdf_has(Id, amalgame:wasGeneratedBy, Process, OutputType),
diff --git a/lib/amalgame/scheme_stats.pl b/lib/amalgame/scheme_stats.pl
index dec1231..6a9b92a 100644
--- a/lib/amalgame/scheme_stats.pl
+++ b/lib/amalgame/scheme_stats.pl
@@ -19,7 +19,7 @@
 %	Stats are statistics for Concepts in Scheme.
 %
 
-scheme_stats(Scheme, Concepts, Strategy, Stats) :-
+scheme_stats(Scheme, ConceptAssoc, Strategy, Stats) :-
 	Stats = scheme_stats_dict{
 		    '@id': Scheme,
 		    strategy: Strategy,
@@ -42,6 +42,7 @@ scheme_stats(Scheme, Concepts, Strategy, Stats) :-
 	),
 	find_voc_revision(Scheme, Revision),
 	find_voc_version(Scheme, Version),
+	assoc_to_keys(ConceptAssoc, Concepts),
 	length(Concepts, TotalCount),
 	concepts_stats(Concepts, Skos, XLP, XLA),
 	length(Skos, SkosNr),
diff --git a/lib/amalgame/vocabulary.pl b/lib/amalgame/vocabulary.pl
index 4c69782..55e52c4 100644
--- a/lib/amalgame/vocabulary.pl
+++ b/lib/amalgame/vocabulary.pl
@@ -6,6 +6,7 @@
 	  ]).
 
 :- use_module(library(apply)).
+:- use_module(library(assoc)).
 :- use_module(library(lists)).
 :- use_module(library(ordsets)).
 :- use_module(library(option)).
@@ -86,7 +87,7 @@ vocab_member(E, is_mapped(Options)) :-
 	option(strategy(Strategy), Options),
 	all_mapped(Strategy, Type, Mappings, Concepts),
 	!,
-	rb_in(E, _, Concepts).
+	get_assoc(E, Concepts, _).
 
 vocab_member(F, 'http://sws.geonames.org/') :-
 	!,
@@ -97,6 +98,12 @@ vocab_member(E, Scheme) :-
 	!,
 	vocab_member(E, scheme(Scheme)).
 
+vocab_member(E, Assoc) :-
+	Assoc = t(_,_,_,_,_),
+	(   ground(E)
+	->  get_assoc(E, Assoc, _)
+	;   gen_assoc(E, Assoc, _)
+	).
 vocab_member(E, Scheme) :-
 	atom(Scheme),
 	rdfs_individual_of(Scheme, amalgame:'Alignable'),