amalgame/commit

ADDED: compute label stats on source and target concept sets in mapping

authorJacco van Ossenbruggen
Mon May 11 19:38:23 2015 +0200
committerJacco van Ossenbruggen
Mon May 11 19:39:12 2015 +0200
commitc77cbe65bd720762e872d11966baf90d4dfd45f9
treebd070d07a2d05b67a156ef7524d9c16aec44262e
parentc98e42c60b4f3d058d3da323122bb84facf87753
Diff style: patch stat
diff --git a/api/node_info.pl b/api/node_info.pl
index d2b881a..79dfeea 100644
--- a/api/node_info.pl
+++ b/api/node_info.pl
@@ -18,7 +18,6 @@
 :- use_module(library(amalgame/amalgame_modules)).
 :- use_module(library(amalgame/ag_strategy)).
 :- use_module(library(amalgame/ag_stats)).
-:- use_module(library(amalgame/scheme_stats)).
 :- use_module(library(amalgame/util)).
 :- use_module(components(label)). % we need rdf_link//1 from this module
 
@@ -187,7 +186,12 @@ amalgame_info(URL, Strategy, Stats) :-
 	->  true
 	;   ReferenceStats = []
 	),
-	PSstats = [], PTstats = [],
+
+	option(labels(Labels), MStats),
+	option(source(SLabels), Labels),     option(target(TLabels), Labels),
+	option(properties(SPDict), SLabels), option(properties(TPDict), TLabels),
+	label_property_stats(SPDict, PSstats, [totalCount(SN0), role(src)]),
+	label_property_stats(TPDict, PTstats, [totalCount(TN0), role(trg)]),
 
 	append([
 	    BasicStats,
@@ -215,8 +219,8 @@ amalgame_info(Scheme, Strategy, Stats) :-
 	    option(totalLabelCount(TotalLabelCount), NStats, 0)
 	->  ExtraStats = [
 		'formats:'   - Formats,
-		'# labels (all properties):'        -  span('~d (~1f l/c)'-[TotalLabelCount, (TotalLabelCount)/Total]),
-		'# counted top concepts:'  - span('~d (~1f%)'-[NrTopConcepts, (100*NrTopConcepts)/Total])
+		'# labels (all properties):' - span('~d (~1f l/c)'-[TotalLabelCount, (TotalLabelCount)/Total]),
+		'# counted top concepts:'    - span('~d (~1f%)'-[NrTopConcepts, (100*NrTopConcepts)/Total])
 			 | DTops
 	    ],
 	    option(topConceptCount(NrTopConcepts), DDict, [])
@@ -250,7 +254,8 @@ amalgame_info(URL, Strategy,
 	append([Definition, Input],Optional).
 
 label_property_stats(Dict, Stats, Options) :-
-	findall(\rdf_link(Property)-set(Values),
+	option(role(Role), Options, ''),
+	findall(span([Role, '/', \rdf_link(Property)])-set(Values),
 		label_property_stat(Dict, Property, Values, Options),
 		Stats).
 
@@ -265,8 +270,10 @@ label_property_stat(Dict, Property, Values, Options) :-
 
 portray_label_stats([],[],_) :- !.
 portray_label_stats([Lang-LDict|TailIn],
-		    [LC-[span([class([key, total])], [Lang, '(total)'])-
+		    [LC-[span([class([key, total])], [Lang, '(labeled cncps)'])-
 			 span([class([value, total])], [TOut]),
+			 span([class([key, lpc])], [Lang, '(label/concept)'])-
+			 span([class([value, lpc])], [LCOut]),
 			 span([class([key, ambig])], [Lang, '(ambig label)'])-
 			 span([class([value, ambig])], [AOut]),
 			 span([class([key, ambig])], [Lang, '(ambig cncps)'])-
@@ -276,11 +283,12 @@ portray_label_stats([Lang-LDict|TailIn],
 	AL = LDict.ambiguousLabelCount,
 	AC = LDict.ambiguousConceptCount,
 	LC = LDict.totalLabelCount,
-
+	TC = LDict.totalConceptCount,
 	option(totalCount(Total), Options, LC),
-	format(atom(TOut), '~w  (~2f%)', [LC, (100*LC)/Total]),
+	format(atom(TOut), '~w  (~2f%)', [TC, (100*TC)/Total]),
 	format(atom(AOut), '~w	(~2f%)', [AL, (100*AL)/Total]),
 	format(atom(COut), '~w	(~2f%)', [AC, (100*AC)/Total]),
+	format(atom(LCOut), '~w	(~2f)',  [LC, (LC/TC)]),
 	portray_label_stats(TailIn, TailOut, Options).
 
 depth_stats(Dict, Stats) :-
diff --git a/lib/amalgame/ag_stats.pl b/lib/amalgame/ag_stats.pl
index e7437bc..be6aaa5 100644
--- a/lib/amalgame/ag_stats.pl
+++ b/lib/amalgame/ag_stats.pl
@@ -92,14 +92,16 @@ mapping_stats(URL, Mapping, Strategy, Stats) :-
 	    totalCount-MN
 	],
 	length(Mapping, MN),
-	maplist(align_source, Mapping, Ss0),
-	maplist(align_target, Mapping, Ts0),
+	maplist(correspondence_source, Mapping, Ss0),
+	maplist(correspondence_target, Mapping, Ts0),
 	sort(Ss0, Ss),	sort(Ts0, Ts),
 
+	compute_label_stats(Ss, SLabelDict),
+	compute_label_stats(Ts, TLabelDict),
 	vocab_stats(URL, Strategy, Ss, Ts, VocStats, StructStats, CarthesianProductSize),
 	input_stats(URL, Strategy, Ss, Ts, MN, CarthesianProductSize, InputStats),
 
-	append([BasicStats, VocStats, StructStats, InputStats], StatsPairs),
+	append([BasicStats, [ labels - label{source:SLabelDict, target:TLabelDict} ], VocStats, StructStats, InputStats], StatsPairs),
 	dict_pairs(Stats,mapping_stats_dict, StatsPairs).
 
 input_stats(URL, Strategy, Ss, Ts, MN, CarthesianProductSize, InputStats) :-
@@ -116,8 +118,8 @@ input_stats(URL, Strategy, Ss, Ts, MN, CarthesianProductSize, InputStats) :-
 	->  maplist(expand_node(Strategy), Inputs, InputMappings),
 	    append(InputMappings, Merged),
 	    sort(Merged, Unique),
-	    maplist(align_source, Unique, Si0),
-	    maplist(align_target, Unique, Ti0),
+	    maplist(correspondence_source, Unique, Si0),
+	    maplist(correspondence_target, Unique, Ti0),
 	    sort(Si0, Si),
 	    sort(Ti0, Ti),
 	    length(Unique, IML),
@@ -132,7 +134,6 @@ input_stats(URL, Strategy, Ss, Ts, MN, CarthesianProductSize, InputStats) :-
 	    TiPerc = 0
 	).
 
-
 vocab_stats(URL, Strategy, Ss, Ts, VocStats, StructStats, CarthesianProductSize) :-
 	mapping_vocab_sources(URL, Strategy, InputS, InputT),
 	node_stats(Strategy, InputS, StatsSin, [compute(deep)]),
@@ -155,6 +156,7 @@ vocab_stats(URL, Strategy, Ss, Ts, VocStats, StructStats, CarthesianProductSize)
 	    sourcePercentage-SPerc,
 	    targetPercentage-TPerc
 	],
+
 	nonvar(StatsSin), Smap = StatsSin.get('@private').get(depthMap),
 	nonvar(StatsTin), Tmap = StatsTin.get('@private').get(depthMap),
 	structure_stats(depth,    Ss, Smap, DSstats),
@@ -169,7 +171,6 @@ vocab_stats(URL, Strategy, Ss, Ts, VocStats, StructStats, CarthesianProductSize)
 	],
 	!.
 
-vocab_stats(_URL, _Strategy, [], [], 0) :-
 
 structure_stats(_,[],_,[]).
 structure_stats(_,[_],_,[]).
@@ -230,8 +231,6 @@ vocab_source(V, Strategy, S) :-
 	vocab_source(Input, Strategy, S).
 vocab_source(V, _S, V).
 
-align_source(align(S,_,_), S).
-align_target(align(_,T,_), T).
 
 compute_reference_counts(Id, Strategy, RefStats) :-
 	reference_mappings(Strategy, References),