amalgame/commit
REFACTORING: Ancestor file and module naming
author | Jacco van Ossenbruggen |
---|---|
Sat Sep 6 15:36:53 2014 +0200 | |
committer | Jacco van Ossenbruggen |
Sat Sep 6 15:43:52 2014 +0200 | |
commit | dc61cc07e110ede2ae24223b0d497dabd59b4d17 |
tree | bd903f37cb13ce54e1da6d952d5ebca09853af3a |
parent | 99b54954910dfea19487b706d7b6eef67915b4db |
Diff style: patch stat
diff --git a/config-available/ag_modules.pl b/config-available/ag_modules.pl index 9fb7528..9f602c5 100644 --- a/config-available/ag_modules.pl +++ b/config-available/ag_modules.pl @@ -1,16 +1,17 @@ :- module(conf_ag_modules, []). % Candidate correspondence generator components: +:- use_module(library(ag_modules/ancestor_generator)). :- use_module(library(ag_modules/exact_label_generator)). % Mapping producing partitioners: +:- use_module(library(ag_modules/ancestor_selecter)). :- use_module(library(ag_modules/exact_label_selecter)). % Modules that can be used as matchers :- use_module(library(ag_modules/compound_match)). :- use_module(library(ag_modules/snowball_match)). :- use_module(library(ag_modules/isub_match)). -:- use_module(library(ag_modules/ancestor_match)). :- use_module(library(ag_modules/descendent_match)). :- use_module(library(ag_modules/related_match)). :- use_module(library(ag_modules/preloaded_mapping)). @@ -23,7 +24,6 @@ :- use_module(library(ag_modules/most_methods)). :- use_module(library(ag_modules/most_labels)). :- use_module(library(ag_modules/most_generic)). -:- use_module(library(ag_modules/ancestor_selecter)). :- use_module(library(ag_modules/descendent_selecter)). :- use_module(library(ag_modules/related_selecter)). :- use_module(library(ag_modules/sibling_selecter)). diff --git a/lib/ag_modules/ancestor.pl b/lib/ag_modules/ancestor.pl deleted file mode 100644 index 8313f27..0000000 --- a/lib/ag_modules/ancestor.pl +++ /dev/null @@ -1,23 +0,0 @@ -:- module(ancestor_match_util, - [ ancestor_match/4 - ]). - -:- use_module(library(semweb/rdf_db)). -:- use_module(library(skos/util)). - -ancestor_match(align(S, T, Prov0), BackgroundMatches, - align(S, T, [Prov|Prov0]), Options) :- - option(steps(MaxSteps), Options), - ancestor(S, MaxSteps, AncS, R1, Steps1), - ancestor(T, MaxSteps, AncT, R2, Steps2), - get_assoc(AncS-AncT, BackgroundMatches, _), - Prov = [method(ancestor_match), - source(AncS), - target(AncT), - steps(Steps1/Steps2), - graph([R1,R2]) - ]. - -ancestor(R, MaxSteps, Parent, rdf(R, Prop, Parent), Steps) :- - skos_descendant_of(Parent, R, MaxSteps, Steps), - rdf_equal(amalgame:ancestor, Prop). diff --git a/lib/ag_modules/ancestor_generator.pl b/lib/ag_modules/ancestor_generator.pl new file mode 100644 index 0000000..4a663b2 --- /dev/null +++ b/lib/ag_modules/ancestor_generator.pl @@ -0,0 +1,35 @@ +:- module(ancestor_generator, + []). + +:- use_module(library(assoc)). +:- use_module(library(lists)). +:- use_module(library(option)). +:- use_module(library(amalgame/vocabulary)). +:- use_module(ancestor_match). + +:- public amalgame_module/1. +:- public matcher/4. +:- public parameter/4. + +amalgame_module(amalgame:'AncestorMatcher'). + +parameter(steps, integer, 1, + 'depth of search, defaults to 1, e.g. direct parents only'). + +%% matcher(+Source, +Target, -Mappings, +Options) +% +% Mappings is a list of matches between instances of Source and +% Target. + +matcher(Source, Target, Mappings, Options) :- + option(snd_input(SecList), Options), + findall(S-T-P, member(align(S,T,P), SecList), KeyValueList), + keysort(KeyValueList, Deduped), + ord_list_to_assoc(Deduped, BackgroundMatches), + findall(M, align(Source, Target, BackgroundMatches, M, Options), Mappings0), + sort(Mappings0, Mappings). + +align(Source, Target, BackgroundMatches, Match, Options) :- + vocab_member(S, Source), + vocab_member(T, Target), + ancestor_match(align(S,T,[]), BackgroundMatches, Match, Options). diff --git a/lib/ag_modules/ancestor_match.pl b/lib/ag_modules/ancestor_match.pl index 09fcc49..9b6031b 100644 --- a/lib/ag_modules/ancestor_match.pl +++ b/lib/ag_modules/ancestor_match.pl @@ -1,35 +1,23 @@ -:- module(ancestor_generator, - []). +:- module(ancestor_match, + [ ancestor_match/4 + ]). -:- use_module(library(assoc)). -:- use_module(library(lists)). -:- use_module(library(option)). -:- use_module(library(amalgame/vocabulary)). -:- use_module(ancestor). +:- use_module(library(semweb/rdf_db)). +:- use_module(library(skos/util)). -:- public amalgame_module/1. -:- public matcher/4. -:- public parameter/4. +ancestor_match(align(S, T, Prov0), BackgroundMatches, + align(S, T, [Prov|Prov0]), Options) :- + option(steps(MaxSteps), Options), + ancestor(S, MaxSteps, AncS, R1, Steps1), + ancestor(T, MaxSteps, AncT, R2, Steps2), + get_assoc(AncS-AncT, BackgroundMatches, _), + Prov = [method(ancestor_match), + source(AncS), + target(AncT), + steps(Steps1/Steps2), + graph([R1,R2]) + ]. -amalgame_module(amalgame:'AncestorMatcher'). - -parameter(steps, integer, 1, - 'depth of search, defaults to 1, e.g. direct parents only'). - -%% matcher(+Source, +Target, -Mappings, +Options) -% -% Mappings is a list of matches between instances of Source and -% Target. - -matcher(Source, Target, Mappings, Options) :- - option(snd_input(SecList), Options), - findall(S-T-P, member(align(S,T,P), SecList), KeyValueList), - keysort(KeyValueList, Deduped), - ord_list_to_assoc(Deduped, BackgroundMatches), - findall(M, align(Source, Target, BackgroundMatches, M, Options), Mappings0), - sort(Mappings0, Mappings). - -align(Source, Target, BackgroundMatches, Match, Options) :- - vocab_member(S, Source), - vocab_member(T, Target), - ancestor_match(align(S,T,[]), BackgroundMatches, Match, Options). +ancestor(R, MaxSteps, Parent, rdf(R, Prop, Parent), Steps) :- + skos_descendant_of(Parent, R, MaxSteps, Steps), + rdf_equal(amalgame:ancestor, Prop). diff --git a/lib/ag_modules/ancestor_selecter.pl b/lib/ag_modules/ancestor_selecter.pl index 3f1e688..091d01f 100644 --- a/lib/ag_modules/ancestor_selecter.pl +++ b/lib/ag_modules/ancestor_selecter.pl @@ -1,7 +1,7 @@ :- module(ancestor_selecter, []). -:- use_module(ancestor). +:- use_module(ancestor_match). :- use_module(structure_selecter). :- public amalgame_module/1. diff --git a/lib/ag_modules/descendent_match.pl b/lib/ag_modules/descendent_generator.pl similarity index 100% rename from lib/ag_modules/descendent_match.pl rename to lib/ag_modules/descendent_generator.pl