amalgame/commit
FIXED: sort_align renaming
author | Jacco van Ossenbruggen |
---|---|
Fri Apr 3 14:43:57 2020 +0200 | |
committer | Jacco van Ossenbruggen |
Fri Apr 3 14:43:57 2020 +0200 | |
commit | d1e2abecfb2c67a5594f3912d5472b16ec54d300 |
tree | f5114eed92f2ed78e73ffbc884f56e847d4d32b5 |
parent | ac0bcbb054ec505bba34620a77a3b019e74e14b0 |
Diff style: patch stat
diff --git a/api/ag_process.pl b/api/ag_process.pl index 8cfa9dd..eec1475 100644 --- a/api/ag_process.pl +++ b/api/ag_process.pl @@ -17,7 +17,7 @@ :- use_module(library(amalgame/ag_provenance)). :- use_module(library(amalgame/ag_strategy)). :- use_module(library(amalgame/json_util)). -:- use_module(library(amalgame/amalgame_modules)). +:- use_module(library(amalgame/rdf_util)). :- setting(amalgame:precompute, boolean, true, @@ -65,7 +65,7 @@ http_add_process(Request) :- subtract(Params0, [input=_,source=_,target=_,process=_,strategy=_,update=_,graphic=_], Params1), findall(secondary_input=S,member(secondary_input=S, Params1), SecParams), subtract(Params1, SecParams, Params), - expand_options(Params, ExpandedParams), + rdf_expand_uri_values(Params, ExpandedParams), flush_refs_cache_if_needed(Process), ( Update == true -> rdf_retractall(Process, amalgame:secondary_input, _, Strategy), diff --git a/lib/ag_modules/arity_select.pl b/lib/ag_modules/arity_select.pl index 12e6e59..5914f3d 100644 --- a/lib/ag_modules/arity_select.pl +++ b/lib/ag_modules/arity_select.pl @@ -62,10 +62,10 @@ select_1_n(Mapping, Sel, Dis) :- maplist(ap(discarded,target), Dis1, Dis). select_1_n_raw(Mapping, Sel, Dis) :- - sort_align(target, Mapping, TargetSorted), + sort_correspondences(target, Mapping, TargetSorted), select_1_n_no_sort(TargetSorted, Sel0, Dis0), - sort_align(source, Sel0, Sel), - sort_align(source, Dis0, Dis). + sort_correspondences(source, Sel0, Sel), + sort_correspondences(source, Dis0, Dis). select_n_1_raw([], [], []). select_n_1_raw([align(S,T,P)|As], A1, A2) :- diff --git a/lib/ag_modules/best_numeric.pl b/lib/ag_modules/best_numeric.pl index 96d759c..a7d9c82 100644 --- a/lib/ag_modules/best_numeric.pl +++ b/lib/ag_modules/best_numeric.pl @@ -24,11 +24,11 @@ selecter(Mapping, Sel, Disc, Und, Options) :- option(type(SourceOrTarget), Options, target), ( SourceOrTarget = target -> partition_(SourceOrTarget, Mapping, Sel, Disc, Und) - ; sort_align(target, Mapping, TSorted), + ; sort_correspondences(target, Mapping, TSorted), partition_(SourceOrTarget, TSorted, Sel0, Disc0, Und0), - sort_align(source, Sel0, Sel), - sort_align(source, Disc0, Disc), - sort_align(source, Und0, Und) + sort_correspondences(source, Sel0, Sel), + sort_correspondences(source, Disc0, Disc), + sort_correspondences(source, Und0, Und) ). diff --git a/lib/ag_modules/label_selecter.pl b/lib/ag_modules/label_selecter.pl index 8b1a504..7c7d0b4 100644 --- a/lib/ag_modules/label_selecter.pl +++ b/lib/ag_modules/label_selecter.pl @@ -18,11 +18,11 @@ label_selecter(Matcher, In, Sel, Dis, Und, Options) :- option(type(SourceOrTarget), Options, all), ( SourceOrTarget \= source -> label_selecter(SourceOrTarget, Matcher, In, Sel, Dis, Und, Options) - ; sort_align(target, In, InT), + ; sort_correspondences(target, In, InT), label_selecter(SourceOrTarget, Matcher, InT, Sel0, Dis0, Und0, Options), - sort_align(source, Sel0, Sel), - sort_align(source, Dis0, Dis), - sort_align(source, Und0, Und) + sort_correspondences(source, Sel0, Sel), + sort_correspondences(source, Dis0, Dis), + sort_correspondences(source, Und0, Und) ). label_selecter( _, _, [], [], [], [], _). diff --git a/lib/ag_modules/most_generic.pl b/lib/ag_modules/most_generic.pl index 0697aa3..561320f 100644 --- a/lib/ag_modules/most_generic.pl +++ b/lib/ag_modules/most_generic.pl @@ -25,11 +25,11 @@ selecter(Mapping, Sel, Disc, Und, Options) :- option(most_least(Most), Options, most), ( SourceOrTarget = target -> partition_(SourceOrTarget, Most, Mapping, Sel, Disc, Und) - ; sort_align(target, Mapping, TSorted), + ; sort_correspondences(target, Mapping, TSorted), partition_(SourceOrTarget, Most, TSorted, Sel0, Disc0, Und0), - sort_align(source, Sel0, Sel), - sort_align(source, Disc0, Disc), - sort_align(source, Und0, Und) + sort_correspondences(source, Sel0, Sel), + sort_correspondences(source, Disc0, Disc), + sort_correspondences(source, Und0, Und) ). method_name(most, most_generic). diff --git a/lib/ag_modules/most_labels.pl b/lib/ag_modules/most_labels.pl index e8a30fb..f7384eb 100644 --- a/lib/ag_modules/most_labels.pl +++ b/lib/ag_modules/most_labels.pl @@ -24,11 +24,11 @@ selecter(Mapping, Sel, Disc, Und, Options) :- option(type(SourceOrTarget), Options, target), ( SourceOrTarget = target -> partition_(SourceOrTarget, Mapping, Sel, Disc, Und) - ; sort_align(target, Mapping, TSorted), + ; sort_correspondences(target, Mapping, TSorted), partition_(SourceOrTarget, TSorted, Sel0, Disc0, Und0), - sort_align(source, Sel0, Sel), - sort_align(source, Disc0, Disc), - sort_align(source, Und0, Und) + sort_correspondences(source, Sel0, Sel), + sort_correspondences(source, Disc0, Disc), + sort_correspondences(source, Und0, Und) ). %% partition(+Input, -Output, +Options) diff --git a/lib/ag_modules/most_methods.pl b/lib/ag_modules/most_methods.pl index 03b88fa..621bfb3 100644 --- a/lib/ag_modules/most_methods.pl +++ b/lib/ag_modules/most_methods.pl @@ -27,11 +27,11 @@ selecter(Mapping, S, D, U, Options) :- partition_(target, Mapping, S, D, U). selecter(Mapping, S, D, U, Options) :- option(type(source), Options, target),!, - sort_align(target, Mapping, TSorted), + sort_correspondences(target, Mapping, TSorted), partition_(source, TSorted, Sel0, Disc0, Und0), - sort_align(source, Sel0, S), - sort_align(source, Disc0, D), - sort_align(source, Und0, U). + sort_correspondences(source, Sel0, S), + sort_correspondences(source, Disc0, D), + sort_correspondences(source, Und0, U). ap(Type, Result, align(S,T,P), align(S,T,Pnew)) :- append([[method(most_methods), diff --git a/lib/ag_modules/sibling_selecter.pl b/lib/ag_modules/sibling_selecter.pl index 65f3b66..37b73cf 100644 --- a/lib/ag_modules/sibling_selecter.pl +++ b/lib/ag_modules/sibling_selecter.pl @@ -30,10 +30,10 @@ selecter(SSorted, Sel, [], Und, Options) :- option(type(SourceOrTarget), Options, source), ( SourceOrTarget = target -> partition_(SourceOrTarget, SSorted, MaxDepth, Sel, Und) - ; sort_align(target, SSorted, TSorted), + ; sort_correspondences(target, SSorted, TSorted), partition_(SourceOrTarget, TSorted, MaxDepth, Sel0, Und0), - sort_align(source, Sel0, Sel), - sort_align(source, Und0, Und) + sort_correspondences(source, Sel0, Sel), + sort_correspondences(source, Und0, Und) ). ac(Result, Type, Length, align(S,T,P), align(S,T,Pnew)) :- append(P, [[method(sibling_select), diff --git a/lib/ag_modules/structure_selecter.pl b/lib/ag_modules/structure_selecter.pl index bf0c54c..e017339 100644 --- a/lib/ag_modules/structure_selecter.pl +++ b/lib/ag_modules/structure_selecter.pl @@ -24,11 +24,11 @@ selecter(Matcher, In, Sel, Dis, Und, Options) :- ord_list_to_assoc(Deduped, BackgroundMatches), ( SourceOrTarget \= source -> selecter_(SourceOrTarget, Matcher, In, BackgroundMatches, Sel, Dis, Und, Options) - ; sort_align(target, In, InT), + ; sort_correspondences(target, In, InT), selecter_(SourceOrTarget, Matcher, InT, BackgroundMatches, Sel0, Dis0, Und0, Options), - sort_align(source, Sel0, Sel), - sort_align(source, Dis0, Dis), - sort_align(source, Und0, Und) + sort_correspondences(source, Sel0, Sel), + sort_correspondences(source, Dis0, Dis), + sort_correspondences(source, Und0, Und) ). selecter_(_, _, [], _, [], [], [], _). diff --git a/lib/amalgame/amalgame_modules.pl b/lib/amalgame/amalgame_modules.pl index ac52975..43cfd16 100644 --- a/lib/amalgame/amalgame_modules.pl +++ b/lib/amalgame/amalgame_modules.pl @@ -4,8 +4,7 @@ amalgame_modules_of_type/2, % +Class, -Modules amalgame_module_parameters/2, % +Module, -Parameters amalgame_module_property/2, % +URI, ?Term, - process_options/3, - expand_options/2 + process_options/3 ]). :- use_module(library(semweb/rdf11)). @@ -13,6 +12,7 @@ :- use_module(library(semweb/rdf_label)). :- use_module(library(http/http_path)). :- use_module(library(http/http_parameters)). +:- use_module(library(amalgame/rdf_util)). :- rdf_meta amalgame_module_property(r,?), @@ -115,24 +115,11 @@ process_options(Process, Module, Options) :- !, module_options(Module, Options, Parameters), parse_url_search(ParamText, Search0), - expand_options(Search0, Search), + rdf_expand_uri_values(Search0, Search), Request = [search(Search)] , http_parameters(Request, Parameters). process_options(_, _, []). -%% expand_options(Pairs, ExpandedPairs) is det. -% -% Expand values using rdf_global_id if not already expanded. - -expand_options([''],[]). -expand_options([],[]). -expand_options([Key=Value|Tail], [Key=FixedValue|Results]):- - atomic_list_concat([NS,L], :, Value), - catch(rdf_global_id(NS:L,FixedValue),_,fail), - expand_options(Tail, Results). -expand_options([Key=Value|Tail], [Key=Value|Results]) :- - expand_options(Tail, Results). - %% module_options(+Module, -Options, -Parameters) % diff --git a/lib/amalgame/rdf_util.pl b/lib/amalgame/rdf_util.pl index 39cea9b..40e198a 100644 --- a/lib/amalgame/rdf_util.pl +++ b/lib/amalgame/rdf_util.pl @@ -6,6 +6,7 @@ rdf_remove_resource/2, rdf_lang/3, rdf_lang/4, + rdf_expand_uri_values/2, rdf_literal_predicates/1 ]). @@ -141,3 +142,16 @@ literal_object_lit(Subject, Predicate, Literal) :- ), rdf_is_literal(Literal). + +%% rdf_expand_uri_values(Pairs, ExpandedPairs) is det. +% +% Expand values using rdf_global_id if not already expanded. + +rdf_expand_uri_values([''],[]). +rdf_expand_uri_values([],[]). +rdf_expand_uri_values([Key=Value|Tail], [Key=FixedValue|Results]):- + atomic_list_concat([NS,L], :, Value), + catch(rdf_global_id(NS:L,FixedValue),_,fail), + rdf_expand_uri_values(Tail, Results). +rdf_expand_uri_values([Key=Value|Tail], [Key=Value|Results]) :- + rdf_expand_uri_values(Tail, Results).