amalgame/commit
REFACTORING: map.pl into correspondence.pl and mapping_graph.pl
author | Jacco van Ossenbruggen |
---|---|
Fri Apr 3 12:28:08 2020 +0200 | |
committer | Jacco van Ossenbruggen |
Fri Apr 3 12:28:08 2020 +0200 | |
commit | ac0bcbb054ec505bba34620a77a3b019e74e14b0 |
tree | 3b38bf1791b84128ceffa356488cda0179a3830b |
parent | 0d47f57af3cd76e922195c50520ac42293f05dbe |
Diff style: patch stat
diff --git a/api/correspondence.pl b/api/correspondence.pl index d264260..c7052fd 100644 --- a/api/correspondence.pl +++ b/api/correspondence.pl @@ -8,7 +8,7 @@ :- use_module(library(http/html_write)). :- use_module(library(semweb/rdf11)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/mapping_graph)). :- use_module(library(amalgame/expand_graph)). :- use_module(components(amalgame/correspondence)). diff --git a/api/evaluate.pl b/api/evaluate.pl index 15742a4..0cf5fed 100644 --- a/api/evaluate.pl +++ b/api/evaluate.pl @@ -20,7 +20,7 @@ :- use_module(library(amalgame/ag_evaluation)). :- use_module(library(amalgame/ag_stats)). :- use_module(library(amalgame/edoal)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/mapping_graph)). :- use_module(library(amalgame/expand_graph)). :- use_module(library(amalgame/util)). diff --git a/api/hints.pl b/api/hints.pl index 5c4359a..f70c5f7 100644 --- a/api/hints.pl +++ b/api/hints.pl @@ -9,7 +9,7 @@ :- use_module(library(semweb/rdf_label)). :- use_module(library(amalgame/ag_strategy)). :- use_module(library(amalgame/ag_stats)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/mapping_graph)). :- http_handler(amalgame(data/hint), http_json_hint, []). diff --git a/api/mapping.pl b/api/mapping.pl index 5a2ebb7..6fc195b 100644 --- a/api/mapping.pl +++ b/api/mapping.pl @@ -17,7 +17,7 @@ :- use_module(library(skos/util)). :- use_module(library(amalgame/ag_stats)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/mapping_graph)). :- use_module(library(amalgame/expand_graph)). :- use_module(library(amalgame/util)). diff --git a/api/strategy_viz.pl b/api/strategy_viz.pl index abae519..9f15515 100644 --- a/api/strategy_viz.pl +++ b/api/strategy_viz.pl @@ -13,7 +13,7 @@ :- use_module(library(amalgame/ag_strategy)). :- use_module(library(amalgame/ag_stats)). :- use_module(library(amalgame/ag_evaluation)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/mapping_graph)). :- use_module(library(amalgame/vocabulary)). :- http_handler(amalgame(api/strategy_viz), http_strategy_viz, []). diff --git a/applications/publisher.pl b/applications/publisher.pl index 60cc565..ac97db3 100644 --- a/applications/publisher.pl +++ b/applications/publisher.pl @@ -9,7 +9,7 @@ :- use_module(library(http/http_dispatch)). :- use_module(library(semweb/rdf11)). :- use_module(library(amalgame/ag_publish)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/mapping_graph)). :- use_module(components(amalgame/util)). :- setting(amalgame:default_publish_namespace, atom, 'http://localhost/ns/', diff --git a/components/amalgame/controls.pl b/components/amalgame/controls.pl index d74eb7d..9e64e79 100644 --- a/components/amalgame/controls.pl +++ b/components/amalgame/controls.pl @@ -6,7 +6,7 @@ :- use_module(library(semweb/rdfs)). :- use_module(library(http/html_write)). :- use_module(library(amalgame/amalgame_modules)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/mapping_graph)). :- use_module(components(amalgame/util)). html_controls --> diff --git a/lib/ag_drivers/exec_amalgame_process.pl b/lib/ag_drivers/exec_amalgame_process.pl index 1c3b4f5..edab2d6 100644 --- a/lib/ag_drivers/exec_amalgame_process.pl +++ b/lib/ag_drivers/exec_amalgame_process.pl @@ -12,7 +12,7 @@ :- use_module(library(semweb/rdf11)). :- use_module(library(semweb/rdfs)). :- use_module(library(amalgame/expand_graph)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- use_module(library(ag_modules/map_merger)). :- multifile diff --git a/lib/ag_modules/ag_overlap.pl b/lib/ag_modules/ag_overlap.pl index 5cf9e30..4cb0ef3 100644 --- a/lib/ag_modules/ag_overlap.pl +++ b/lib/ag_modules/ag_overlap.pl @@ -8,7 +8,7 @@ :- use_module(library(semweb/rdf11)). :- use_module(library(semweb/rdf_label)). :- use_module(library(amalgame/expand_graph)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- public amalgame_module/1. :- public analyzer/5. diff --git a/lib/ag_modules/ancestor_generator.pl b/lib/ag_modules/ancestor_generator.pl index c9dbb19..46ced69 100644 --- a/lib/ag_modules/ancestor_generator.pl +++ b/lib/ag_modules/ancestor_generator.pl @@ -1,7 +1,6 @@ :- module(ancestor_generator, []). -:- use_module(library(amalgame/ag_strategy)). :- use_module(ancestor_match). :- use_module(generator_snd_input). diff --git a/lib/ag_modules/arity_select.pl b/lib/ag_modules/arity_select.pl index 6ff3eb2..12e6e59 100644 --- a/lib/ag_modules/arity_select.pl +++ b/lib/ag_modules/arity_select.pl @@ -1,6 +1,6 @@ :- module(arity_select,[]). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- public amalgame_module/1. :- public selecter/5. diff --git a/lib/ag_modules/best_numeric.pl b/lib/ag_modules/best_numeric.pl index efe0809..96d759c 100644 --- a/lib/ag_modules/best_numeric.pl +++ b/lib/ag_modules/best_numeric.pl @@ -3,7 +3,7 @@ :- use_module(library(lists)). :- use_module(library(option)). :- use_module(library(pairs)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- public amalgame_module/1. :- public selecter/5. diff --git a/lib/ag_modules/label_selecter.pl b/lib/ag_modules/label_selecter.pl index ac6d6ac..8b1a504 100644 --- a/lib/ag_modules/label_selecter.pl +++ b/lib/ag_modules/label_selecter.pl @@ -10,7 +10,7 @@ :- use_module(library(lists)). :- use_module(library(option)). :- use_module(library(pairs)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- meta_predicate label_selecter(3, +, -, -, -, +). diff --git a/lib/ag_modules/map_merger.pl b/lib/ag_modules/map_merger.pl index 621c2ec..76870a4 100644 --- a/lib/ag_modules/map_merger.pl +++ b/lib/ag_modules/map_merger.pl @@ -3,7 +3,7 @@ ]). :- use_module(library(lists)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- public amalgame_module/1. :- public merger/3. diff --git a/lib/ag_modules/most_generic.pl b/lib/ag_modules/most_generic.pl index 0afd5fd..0697aa3 100644 --- a/lib/ag_modules/most_generic.pl +++ b/lib/ag_modules/most_generic.pl @@ -1,7 +1,7 @@ :- module(most_generic,[]). :- use_module(library(skos/util)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- public amalgame_module/1. :- public selecter/5. diff --git a/lib/ag_modules/most_labels.pl b/lib/ag_modules/most_labels.pl index d010d6e..e8a30fb 100644 --- a/lib/ag_modules/most_labels.pl +++ b/lib/ag_modules/most_labels.pl @@ -1,6 +1,6 @@ :- module(most_labels, []). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- public amalgame_module/1. :- public selecter/5. diff --git a/lib/ag_modules/most_methods.pl b/lib/ag_modules/most_methods.pl index 98928ef..03b88fa 100644 --- a/lib/ag_modules/most_methods.pl +++ b/lib/ag_modules/most_methods.pl @@ -5,7 +5,7 @@ :- use_module(library(option)). :- use_module(library(pairs)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- public amalgame_module/1. :- public selecter/5. diff --git a/lib/ag_modules/preloaded_mapping.pl b/lib/ag_modules/preloaded_mapping.pl index 6e13154..7db2035 100644 --- a/lib/ag_modules/preloaded_mapping.pl +++ b/lib/ag_modules/preloaded_mapping.pl @@ -3,7 +3,7 @@ :- use_module(library(option)). :- use_module(library(semweb/rdf11)). :- use_module(library(semweb/rdfs)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- use_module(library(amalgame/vocabulary)). :- public amalgame_module/1. diff --git a/lib/ag_modules/preloaded_selecter.pl b/lib/ag_modules/preloaded_selecter.pl index ce34d22..6eace0c 100644 --- a/lib/ag_modules/preloaded_selecter.pl +++ b/lib/ag_modules/preloaded_selecter.pl @@ -2,7 +2,7 @@ :- use_module(library(semweb/rdf11)). :- use_module(library(semweb/rdfs)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- public amalgame_module/1. :- public selecter/5. diff --git a/lib/ag_modules/sibling_selecter.pl b/lib/ag_modules/sibling_selecter.pl index 716cf49..65f3b66 100644 --- a/lib/ag_modules/sibling_selecter.pl +++ b/lib/ag_modules/sibling_selecter.pl @@ -4,7 +4,7 @@ :- use_module(library(lists)). :- use_module(library(option)). :- use_module(library(skos/util)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- use_module(library(semweb/rdf_label)). :- public amalgame_module/1. diff --git a/lib/ag_modules/structure_selecter.pl b/lib/ag_modules/structure_selecter.pl index 7b0f746..bf0c54c 100644 --- a/lib/ag_modules/structure_selecter.pl +++ b/lib/ag_modules/structure_selecter.pl @@ -12,7 +12,7 @@ :- use_module(library(option)). :- use_module(library(pairs)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). :- meta_predicate selecter(4, +, -, -, -, +). diff --git a/lib/amalgame/ag_publish.pl b/lib/amalgame/ag_publish.pl index b12731b..0c0ff5c 100644 --- a/lib/amalgame/ag_publish.pl +++ b/lib/amalgame/ag_publish.pl @@ -18,7 +18,7 @@ :- use_module(library(amalgame/vocabulary)). :- use_module(library(amalgame/expand_graph)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/mapping_graph)). :- use_module(library(amalgame/edoal)). save_results(Strategy, Dir, Options) :- diff --git a/lib/amalgame/ag_stats.pl b/lib/amalgame/ag_stats.pl index ea8c199..19b4b9c 100644 --- a/lib/amalgame/ag_stats.pl +++ b/lib/amalgame/ag_stats.pl @@ -20,7 +20,8 @@ :- use_module(library(amalgame/caching)). :- use_module(library(amalgame/vocabulary)). :- use_module(library(amalgame/ag_reference)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/mapping_graph)). +:- use_module(library(amalgame/correspondence)). :- use_module(library(amalgame/util)). :- use_module(library(amalgame/json_util)). diff --git a/lib/amalgame/ag_strategy.pl b/lib/amalgame/ag_strategy.pl index e075905..d019b53 100644 --- a/lib/amalgame/ag_strategy.pl +++ b/lib/amalgame/ag_strategy.pl @@ -23,7 +23,7 @@ :- use_module(library(semweb/rdfs)). :- use_module(library(semweb/rdf_label)). :- use_module(library(amalgame/util)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/mapping_graph)). :- use_module(library(amalgame/ag_provenance)). :- use_module(library(amalgame/ag_stats)). :- use_module(user(preferences)). diff --git a/lib/amalgame/caching.pl b/lib/amalgame/caching.pl index 735e47b..e6ebec0 100644 --- a/lib/amalgame/caching.pl +++ b/lib/amalgame/caching.pl @@ -23,7 +23,7 @@ :- use_module(library(semweb/rdfs)). :- use_module(ag_provenance). -:- use_module(map). +:- use_module(mapping_graph). :- use_module(vocabulary). :- use_module(ag_stats). :- use_module(scheme_stats). diff --git a/lib/amalgame/correspondence.pl b/lib/amalgame/correspondence.pl new file mode 100644 index 0000000..17a38cf --- /dev/null +++ b/lib/amalgame/correspondence.pl @@ -0,0 +1,102 @@ +:- module(ag_correspondence, + [ + correspondence_source/2, + correspondence_target/2, + correspondence_evidence/2, + correspondence_element/3, + + sort_correspondences/3, % +Type, +In, -Sorted + same_source/4, % +List, +Source, -Same, -Rest + same_target/4, % +List, +Target, -Same, -Rest + merge_provenance/2 % +List, -Merged + + ] + ). + +/** <module> Amalgame correspondences (map) module + +This module contains predicates to deal with correspondences while +abstracting from the underlying formats. This should converge into a +set of functions around sorted lists with +align(Source,Target,EvidenceList) terms. + +@author Jacco van Ossenbruggen +@license LGPL +*/ + +:- use_module(library(lists)). + + +%% correspondence_source(?C,?S) is det. +% +% Unifies S with the source of correspondence C. + +correspondence_source(align(S,_,_), S). + +%% correspondence_target(?C,?T) is det. +% +% Unifies T with the target of correspondence C. +% +correspondence_target(align(_,T,_), T). + +%% correspondence_evidence(?C,?E) is det. +% +% Unifies E with the evidence list of correspondence C. + +correspondence_evidence(align(_,_,E), E). + +correspondence_element(source, C, S) :- correspondence_source(C,S). +correspondence_element(target, C, T) :- correspondence_target(C,T). +correspondence_element(evidence, C, E) :- correspondence_evidence(C,E). + +%% same_source(+List, +Source, -Same, -Rest) is det. +% +% Same contains all alignments from List that have Source as a +% source, Rest contains all alignments with a different source. +% List, Same and Rest are assumed to be the usual lists of +% amalgame's align(S,T,P), sorted on S. + +same_source([align(S,T,P)|As], S, [align(S,T,P)|Same], Rest) :- + !, same_source(As, S, Same, Rest). +same_source(As, _S, [], As). + +%% same_target(+List, +Target, -Same, -Rest) is det. +% +% Same contains all alignments from List that have Target as a +% target, Rest contains all alignments with a different target. +% List, Same and Rest are assumed to be the usual lists of +% amalgame's align(S,T,P), sorted on T. + +same_target([align(S,T,P)|As], T, [align(S,T,P)|Same], Rest) :- + !, same_target(As, T, Same, Rest). +same_target(As, _S, [], As). + + +%! sort_correspondences(Type, In, Out) is det. +% +% Sort list of correspondences on source or target. + +sort_correspondences(source, In, Out) :- + sort(In, Out). + +sort_correspondences(target, In, Out) :- + sort(In, In0), + sort(2, @=<, In0, Out). + +%% merge_provenance(+AlignIn, -AlignOut) +% +% Collects all provenance for similar source target pairs. +% AlignIn is a sorted list of align/3 terms. + +merge_provenance([], []). +merge_provenance([align(S, T, P)|As], Gs) :- + group_provenance(As, S, T, P, Gs). + +group_provenance([align(S,T,P)|As], S, T, P0, Gs) :- + !, + append(P, P0, P1), + group_provenance(As, S, T, P1, Gs). +group_provenance(As, S, T, P, [align(S, T, Psorted)|Gs]) :- + sort(P, Psorted), + merge_provenance(As, Gs). + diff --git a/lib/amalgame/edoal.pl b/lib/amalgame/edoal.pl index ae38840..852f7c8 100644 --- a/lib/amalgame/edoal.pl +++ b/lib/amalgame/edoal.pl @@ -18,7 +18,6 @@ http://alignapi.gforge.inria.fr/edoal.html :- use_module(library(semweb/rdf11)). -:- use_module(map). :- use_module(ag_provenance). %% assert_alignment(+URI, +OptionList) is det. diff --git a/lib/amalgame/expand_graph.pl b/lib/amalgame/expand_graph.pl index a36f023..449ce51 100644 --- a/lib/amalgame/expand_graph.pl +++ b/lib/amalgame/expand_graph.pl @@ -16,7 +16,8 @@ :- use_module(library(skos/util)). :- use_module(library(amalgame/caching)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/correspondence)). +:- use_module(library(amalgame/mapping_graph)). :- use_module(library(amalgame/vocabulary)). :- use_module(library(amalgame/ag_provenance)). :- use_module(library(amalgame/amalgame_modules)). diff --git a/lib/amalgame/json_util.pl b/lib/amalgame/json_util.pl index 32b7cc2..afb5cba 100644 --- a/lib/amalgame/json_util.pl +++ b/lib/amalgame/json_util.pl @@ -11,7 +11,7 @@ :- use_module(library(amalgame/ag_strategy)). :- use_module(library(amalgame/ag_stats)). -:- use_module(library(amalgame/map)). +:- use_module(library(amalgame/mapping_graph)). :- use_module(library(amalgame/ag_stats)). :- use_module(library(amalgame/ag_reference)). :- use_module(library(amalgame/ag_evaluation)). diff --git a/lib/amalgame/map.pl b/lib/amalgame/mapping_graph.pl similarity index 75% rename from lib/amalgame/map.pl rename to lib/amalgame/mapping_graph.pl index a2b9369..0b0e64a 100644 --- a/lib/amalgame/map.pl +++ b/lib/amalgame/mapping_graph.pl @@ -1,11 +1,7 @@ -:- module(ag_map, +:- module(ag_mapping_graph, [has_correspondence/2, % align/3, MappingGraph URI has_correspondence_chk/2, remove_correspondence/2, % align/3, MappingGraph URI - correspondence_source/2, - correspondence_target/2, - correspondence_evidence/2, - correspondence_element/3, map_nickname/3, % +Strategy, +MappingGraph, ?Nickname map_localname/3, % +Strategy, +MappingGraph, ?Localname @@ -14,24 +10,16 @@ augment_relations/4, mapping_relation/2, - materialize_mapping_graph/2, % +List, +Options - merge_provenance/2, % +List, -Merged - - sort_align/3, % +Type, +In, -Sorted - same_source/4, % +List, +Source, -Same, -Rest - same_target/4, % +List, +Target, -Same, -Rest + materialize_mapping_graph/2, % +List, +Optios supported_map_relations/1, % ?URIList - status_option/1 ] ). -/** <module> Amalgame correspondences (map) module +/** <module> Amalgame mapping_graph module -This module contains predicates to deal with correspondences while -abstracting from the underlying formats. This should converge into a -set of functions around sorted lists with -align(Source,Target,EvidenceList) terms. +This module contains predicates to deal with correspondences stored in +an rdf amed graph. @author Jacco van Ossenbruggen @license LGPL @@ -63,49 +51,6 @@ status_option(amalgame:intermediate). status_option(amalgame:discarded). status_option(amalgame:reference). -%% correspondence_source(?C,?S) is det. -% -% Unifies S with the source of correspondence C. - -correspondence_source(align(S,_,_), S). - -%% correspondence_target(?C,?T) is det. -% -% Unifies T with the target of correspondence C. -% -correspondence_target(align(_,T,_), T). - -%% correspondence_evidence(?C,?E) is det. -% -% Unifies E with the evidence list of correspondence C. - -correspondence_evidence(align(_,_,E), E). - -correspondence_element(source, C, S) :- correspondence_source(C,S). -correspondence_element(target, C, T) :- correspondence_target(C,T). -correspondence_element(evidence, C, E) :- correspondence_evidence(C,E). - -%% same_source(+List, +Source, -Same, -Rest) is det. -% -% Same contains all alignments from List that have Source as a -% source, Rest contains all alignments with a different source. -% List, Same and Rest are assumed to be the usual lists of -% amalgame's align(S,T,P), sorted on S. - -same_source([align(S,T,P)|As], S, [align(S,T,P)|Same], Rest) :- - !, same_source(As, S, Same, Rest). -same_source(As, _S, [], As). - -%% same_target(+List, +Target, -Same, -Rest) is det. -% -% Same contains all alignments from List that have Target as a -% target, Rest contains all alignments with a different target. -% List, Same and Rest are assumed to be the usual lists of -% amalgame's align(S,T,P), sorted on T. - -same_target([align(S,T,P)|As], T, [align(S,T,P)|Same], Rest) :- - !, same_target(As, T, Same, Rest). -same_target(As, _S, [], As). %% has_correspondence(?C, +G) is nondet. % @@ -285,42 +230,7 @@ atom_to_skos_relation(URL, URL) :- !. prolog:message(map(found, What, From, Number)) --> [ 'Found ', Number, ' ', What, ' (', From, ') to process.' ]. -prolog:message(map(cleared, What, From, Number)) --> - [ 'Cleared ', Number, ' ', What, ' (', From, ').' ]. -prolog:message(map(created, What, From, _Number)) --> - [ 'Created ', What, ' (', From, ').' ]. -prolog:message(map(occurs_min(Min, MappingList))) --> - { length(MappingList,MLL) }, - [ 'Occurs in min ~w mapping graphs: ~w'-[Min, MLL] ]. - -%! sort_align(Type, In, Out) is det. -% -% Sort list of correspondences on source or target. - -sort_align(source, In, Out) :- - sort(In, Out). - -sort_align(target, In, Out) :- - sort(In, In0), - sort(2, @=<, In0, Out). - -%% merge_provenance(+AlignIn, -AlignOut) -% -% Collects all provenance for similar source target pairs. -% AlignIn is a sorted list of align/3 terms. - -merge_provenance([], []). -merge_provenance([align(S, T, P)|As], Gs) :- - group_provenance(As, S, T, P, Gs). - -group_provenance([align(S,T,P)|As], S, T, P0, Gs) :- - !, - append(P, P0, P1), - group_provenance(As, S, T, P1, Gs). -group_provenance(As, S, T, P, [align(S, T, Psorted)|Gs]) :- - sort(P, Psorted), - merge_provenance(As, Gs). %% materialize_alignment_graph(+Mappings, +Options)