amalgame/commit
CHANGED: all vocab selecters have now been turned into vocab partioners
author | Jacco van Ossenbruggen |
---|---|
Wed Sep 3 08:43:14 2014 +0200 | |
committer | Jacco van Ossenbruggen |
Wed Sep 3 08:43:14 2014 +0200 | |
commit | 40c6387987a3f602f875b3b5f328ff3333856441 |
tree | c9b4f3849c14e4c622508cb1c8e4e48a3b272969 |
parent | 825167639e8d8aad7baa6188aec1a227304955d7 |
Diff style: patch stat
diff --git a/lib/ag_drivers/exec_amalgame_process.pl b/lib/ag_drivers/exec_amalgame_process.pl index d3b7914..246e31f 100644 --- a/lib/ag_drivers/exec_amalgame_process.pl +++ b/lib/ag_drivers/exec_amalgame_process.pl @@ -136,16 +136,6 @@ exec_amalgame_process(Class, Process, Strategy, Module, MapSpec, Time, Options) % We need the ids, not the values in most analyzers timed_call(Module:analyzer(Inputs, Process, Strategy, Result, Options), Time), MapSpec = mapspec(Result). % Result = overlap([..]). -exec_amalgame_process(Class, Process, Strategy, Module, VocSpec, Time, Options) :- - rdfs_subclass_of(Class, amalgame:'VocabSelecter'), - !, - once(rdf(Process, amalgame:input, Input, Strategy)), - findall(S, rdf_has(Process, amalgame:secondary_input, S), Ss), - - expand_node(Strategy, Input, vocspec(Vocab)), - timed_call(Module:selecter(Vocab, Result, - [snd_input(Ss), strategy(Strategy)|Options]), Time), - VocSpec=vocspec(Result). % vocspec(and(_,_)) exec_amalgame_process(Class, Process, Strategy, Module, VocSpec, Time, Options) :- rdfs_subclass_of(Class, amalgame:'VocabPartitioner'), !, @@ -153,7 +143,7 @@ exec_amalgame_process(Class, Process, Strategy, Module, VocSpec, Time, Options) findall(S, rdf_has(Process, amalgame:secondary_input, S), Ss), VocSpec = vocspec(select(Selected, Discarded, Undecided)), expand_node(Strategy, Input, InputVocspec), - timed_call(Module:partition(InputVocspec, Selected, Discarded, Undecided, + timed_call(Module:selecter(InputVocspec, Selected, Discarded, Undecided, [snd_input(Ss), strategy(Strategy)|Options]), Time). exec_amalgame_process(Class, Process,_,_, _, _, _) :- throw(error(existence_error(mapping_process, [Class, Process]), _)). diff --git a/lib/ag_modules/propvalue_select.pl b/lib/ag_modules/propvalue_select.pl index a9707e0..180e3d5 100644 --- a/lib/ag_modules/propvalue_select.pl +++ b/lib/ag_modules/propvalue_select.pl @@ -2,7 +2,7 @@ :- public amalgame_module/1. :- public parameter/4. -:- public selecter/3. +:- public selecter/5. amalgame_module(amalgame:'PropertyValueSelect'). @@ -13,15 +13,12 @@ parameter(value, uri, any, parameter(mode, oneof([select, remove]), select, 'select or remove concepts with this property/value pair'). -% a bit naive at the moment: we simply change the query that should be -% done. - -selecter(Scheme, and((Scheme), propvalue(Property, Value)), Options) :- - option(mode(select), Options), - option(property(Property), Options), - option(value(Value), Options). - -selecter(Scheme, and((Scheme), not(propvalue(Property, Value))), Options) :- - option(mode(remove), Options), +selecter(VocSpec, Sel, Dis, [], Options) :- option(property(Property), Options), - option(value(Value), Options). + option(value(Value), Options), + S = and((VocSpec), propvalue(Property, Value)), + D = and((VocSpec), not(propvalue(Property, Value))), + ( option(mode(select), Options, select) + -> Sel = S, Dis = D + ; Sel = D, Dis = S + ). diff --git a/lib/ag_modules/subtree_select.pl b/lib/ag_modules/subtree_select.pl index 8f6cd54..49f2497 100644 --- a/lib/ag_modules/subtree_select.pl +++ b/lib/ag_modules/subtree_select.pl @@ -6,27 +6,27 @@ :- public amalgame_module/1. :- public parameter/4. -:- public selecter/3. +:- public selecter/5. amalgame_module(amalgame:'SubtreeSelect'). parameter(parent, uri, '', -'Concept that is the top concept of the subtree'). -parameter(mode, oneof([select, remove]), select, 'select or remove concepts from this subtree'). - -% a bit naive at the moment: we simply change the query that should be -% done. - -selecter(Scheme, and((Scheme), subtree(Parent)), Options) :- - option(mode(select), Options), - option(parent(Parent), Options). - -selecter(Scheme, and((Scheme), not(subtree(Parent))), Options) :- - option(mode(remove), Options), - option(parent(Parent), Options). - -% Add class 'concept' to the input form so we can use the values from -% the concept browser to assist the user in filling in the form: + 'Concept that is the top concept of the subtree'). +parameter(mode, oneof([select, remove]), select, + 'select or remove concepts from this subtree'). + +selecter(VocSpec, Sel, Dis, [], Options) :- + option(parent(Parent), Options), + S = and((VocSpec), subtree(Parent)), + D = and((VocSpec), not(subtree(Parent))), + ( option(mode(select), Options, select) + -> Sel = S, Dis = D + ; Sel = D, Dis = S + ). + +% Add class 'concept' to the input form in components(amalgame/util) so +% we can use the values from the concept browser to assist the user in +% filling in the parent parameter in the html form: amalgame:input_item(uri, Value, parent) --> html(input([name(parent), class(concept), value(Value)])). diff --git a/lib/ag_modules/type_select.pl b/lib/ag_modules/type_select.pl index 6c43648..5e16693 100644 --- a/lib/ag_modules/type_select.pl +++ b/lib/ag_modules/type_select.pl @@ -2,25 +2,16 @@ :- public amalgame_module/1. :- public parameter/4. -:- public selecter/3. -:- public partition/5. +:- public selecter/5. amalgame_module(amalgame:'TypeSelect'). -amalgame_module(amalgame:'TypePartition'). parameter(class, uri, '', 'rdfs:Class from which to select the concepts'). parameter(mode, oneof([select, remove]), select, 'select or remove concepts of this type'). -selecter(Scheme, and((Scheme), type(Class)), Options) :- - option(mode(select), Options), - option(class(Class), Options). -selecter(Scheme, and((Scheme), not(type(Class))), Options) :- - option(mode(remove), Options), - option(class(Class), Options). - -partition(VocSpec, Sel, Dis, [], Options) :- +selecter(VocSpec, Sel, Dis, [], Options) :- option(mode(select), Options), option(class(Class), Options), Sel = and((VocSpec), type(Class)), diff --git a/lib/ag_modules/voc_exclude.pl b/lib/ag_modules/voc_exclude.pl index 04d7ead..5468474 100644 --- a/lib/ag_modules/voc_exclude.pl +++ b/lib/ag_modules/voc_exclude.pl @@ -2,12 +2,21 @@ :- public amalgame_module/1. :- public parameter/4. -:- public selecter/3. +:- public selecter/5. amalgame_module(amalgame:'VocExclude'). parameter(type, oneof([source,target]), source, 'Exclude matching sources or targets'). +parameter(mode, oneof([select, remove]), select, + 'select or remove concepts of this type'). + +selecter(VocSpec, Sel, Dis, [], Options) :- + S = and((VocSpec), not(is_mapped(Options))), + D = and((VocSpec), is_mapped(Options)), + ( option(mode(select), Options, select) + -> Sel = S, Dis = D + ; Sel = D, Dis = S + ). -selecter(Scheme, and((Scheme), not(is_mapped(Options))), Options). diff --git a/lib/amalgame/hooks/strategy_backward_compatability.pl b/lib/amalgame/hooks/strategy_backward_compatability.pl index 79ab1c7..d7cac20 100644 --- a/lib/amalgame/hooks/strategy_backward_compatability.pl +++ b/lib/amalgame/hooks/strategy_backward_compatability.pl @@ -1,25 +1,49 @@ :- module(strategy_backward_compatability, []). :- use_module(library(lists)). +:- use_module(library(apply)). :- use_module(library(settings)). :- use_module(library(semweb/rdf_db)). :- use_module(library(semweb/rdfs)). +:- use_module(library(skos/util)). +:- use_module(library(amalgame/rdf_util)). +:- use_module(api(ag_process)). % hack: we use ag_process:assert_output :- multifile amalgame:prebuilder/1. +:- rdf_meta + is_old_vocab_selecter_triple(r,r,r,r). + amalgame:prebuilder(Strategy) :- backward_compatibilty_fixes(Strategy). backward_compatibilty_fixes(Strategy) :- + fix_vocab_selecters(Strategy), fix_opmv_ns(Strategy), fix_sec_inputs(Strategy), fix_arity_params(Strategy), fix_publish_ns(Strategy). +fix_vocab_selecters(Strategy) :- + findall(rdf(S,P,O,Strategy), is_old_vocab_selecter_triple(S,P,O,Strategy), OldTriples), + % maplist(old_vocab_selecter_to_new(OldTriples), + rdf_retract_list(OldTriples). + +rdf_retract_list([]). +rdf_retract_list([rdf(S,P,O,G)|T]) :- + rdf_retractall(S,P,O,G), + rdf_retract_list(T). + +is_old_vocab_selecter_triple(S,amalgame:wasGeneratedBy,O, G) :- + rdf(S,amalgame:wasGeneratedBy,O, G), + skos_is_vocabulary(S). + +old_vocab_selecter_to_new(rdf(S,_,Process,Strategy)) :- + ag_process:assert_output(Process, amalgame:'VocabPartitioner', Strategy, _, _, S). + fix_publish_ns(S) :- -% backward compatibility ( rdf(S, amalgame:publish_ns, _,S) -> true ; setting(amalgame:default_publish_namespace, NS), @@ -27,7 +51,6 @@ fix_publish_ns(S) :- ). fix_sec_inputs(Strategy) :- -% backward compatibility findall(rdf(S,RP,O), ( rdf_has(S,amalgame:secondary_input, O, RP), rdf(S, RP, O, Strategy) @@ -37,7 +60,7 @@ fix_sec_inputs(Strategy) :- rdf_assert(S,amalgame:secondary_input, O, Strategy) ) ). -fix_opmv_ns(Strategy) :- % backward compatibility +fix_opmv_ns(Strategy) :- OldProp = 'http://purl.org/net/opmv/ns#wasGeneratedBy', findall(rdf(S,OldProp,O), rdf(S, OldProp, O, Strategy), @@ -49,7 +72,6 @@ fix_opmv_ns(Strategy) :- % backward compatibility ). fix_arity_params(Strategy) :- -% backward compatibility rdf_equal(amalgame:parameters, ParamProp), findall(rdf(S,ParamProp,O), ( rdf(S,ParamProp, literal(O), Strategy), diff --git a/lib/amalgame/util.pl b/lib/amalgame/util.pl index 2643402..c6b1255 100644 --- a/lib/amalgame/util.pl +++ b/lib/amalgame/util.pl @@ -29,6 +29,9 @@ % URI is a new URI in the publish_ns namespace of Strategy, with a % Local part that is equal to gensym(Type, Local), % such that URI is not already a RDF subject or RDF named graph. + +mint_node_uri(_Strategy, _Type, URI) :- + ground(URI),!. mint_node_uri(Strategy, Type, URI) :- ground(Type), ground(Strategy), diff --git a/rdf/tool/ag_modules.ttl b/rdf/tool/ag_modules.ttl index 4f10bc4..108cae9 100644 --- a/rdf/tool/ag_modules.ttl +++ b/rdf/tool/ag_modules.ttl @@ -117,29 +117,24 @@ amalgame:MapMerger amalgame:VocExclude amalgame:need_secondary_inputs true ; - rdfs:label "subtract mapped concepts"@en ; - skos:definition "Subtract from a vocabulary the sources or targets from a given mapping to create a vocabulary with the unmapped concepts."@en ; - rdfs:subClassOf amalgame:VirtualVocabSelecter . - -amalgame:TypePartition - rdfs:label "partition facet on type"@en ; - skos:definition "Partition from a vocabulary based on the concepts being of a specific type or not."@en ; + rdfs:label "partition mapped/unmapped"@en ; + skos:definition "Partition a vocabulary based on the concepts having already been mapped, or not."@en ; rdfs:subClassOf amalgame:VirtualVocabPartitioner . amalgame:TypeSelect - rdfs:label "select facet on type"@en ; - skos:definition "Select from a vocabulary the concepts of a specific type."@en ; - rdfs:subClassOf amalgame:VirtualVocabSelecter . + rdfs:label "partition facet on type"@en ; + skos:definition "Partition a vocabulary based on the concepts being of a specific type, or not."@en ; + rdfs:subClassOf amalgame:VirtualVocabPartitioner . amalgame:PropertyValueSelect rdfs:label "select facet on property/value"@en ; - skos:definition "Select from a vocabulary the concepts with a specific property/value."@en ; - rdfs:subClassOf amalgame:VirtualVocabSelecter . + skos:definition "Partition a vocabulary based on the concepts having a specific property/value, or not."@en ; + rdfs:subClassOf amalgame:VirtualVocabPartitioner . amalgame:SubtreeSelect rdfs:label "select facet by subtree"@en ; - skos:definition "Select from a vocabulary the concepts in the sub-tree below (using BT/NT) a common parent concept."@en ; - rdfs:subClassOf amalgame:VirtualVocabSelecter . + skos:definition "Partition a vocabulary based on the concepts being in the sub-tree below (using BT/NT) a common parent concept, or not."@en ; + rdfs:subClassOf amalgame:VirtualVocabPartitioner . amalgame:OverlapComponent amalgame:need_secondary_inputs true ; diff --git a/rdf/tool/amalgame.ttl b/rdf/tool/amalgame.ttl index 442c812..62a0077 100644 --- a/rdf/tool/amalgame.ttl +++ b/rdf/tool/amalgame.ttl @@ -10,16 +10,16 @@ amalgame:AlignmentStrategy a prov:Plan ; - rdfs:label "alignment strategy"@en ; + rdfs:label "Alignment strategy"@en ; rdfs:comment "RDF representation of an alignment strategy that can be loaded and executed by Amalgame"@en. amalgame:Entity - rdfs:label "entity"@en ; + rdfs:label "Entity"@en ; rdfs:comment "Top class for all amalgame data entities, including mappings and vocabularies"@en ; rdfs:subClassOf prov:Entity . amalgame:Process - rdfs:label "process"@en ; + rdfs:label "Process"@en ; rdfs:comment "Top class for all amalgame processes"@en ; rdfs:subClassOf prov:Activity . @@ -74,38 +74,39 @@ amalgame:includes rdfs:domain skos:ConceptScheme ; rdfs:range amalgame:AlignmentStrategy . amalgame:input - rdfs:domain prov:Activity ; + rdfs:domain amalgame:Activity ; rdfs:range amalgame:Entity ; rdfs:subPropertyOf prov:used. amalgame:secondary_input - rdfs:domain prov:Activity ; + rdfs:domain amalgame:Activity ; rdfs:range amalgame:Entity ; rdfs:subPropertyOf prov:used . amalgame:wasGeneratedBy a rdf:Property ; rdfs:domain amalgame:Entity ; - rdfs:range prov:Activity ; + rdfs:range amalgame:Activity ; rdfs:comment 'The subject can be generated by running the object'@en. amalgame:selectedBy rdfs:domain amalgame:Entity ; - rdfs:range prov:Activity ; + rdfs:range amalgame:Activity ; rdfs:subPropertyOf amalgame:wasGeneratedBy. amalgame:discardedBy rdfs:domain amalgame:Entity ; - rdfs:range prov:Activity ; + rdfs:range amalgame:Activity ; rdfs:subPropertyOf amalgame:wasGeneratedBy. amalgame:undecidedBy rdfs:domain amalgame:Entity ; - rdfs:range prov:Activity ; + rdfs:range amalgame:Activity ; rdfs:subPropertyOf amalgame:wasGeneratedBy. amalgame:evaluationOf rdfs:subPropertyOf prov:wasDerivedFrom. amalgame:Mapping a rdfs:Class ; - rdfs:subClassOf prov:Entity ; + rdfs:subClassOf amalgame:Entity ; rdfs:label "Mapping Graph"@en ; rdfs:comment "The class of all Named Graphs in the repository containing correspondences."@en. amalgame:ConceptScheme + rdfs:subClassOf amalgame:Entity ; rdfs:subClassOf skos:ConceptScheme . amalgame:VirtualConceptScheme rdfs:subClassOf amalgame:ConceptScheme .