xmlrdf/commit

Updated AHM example to reproduce results of the non-cliopatria version.

authorJan Wielemaker
Fri Mar 25 14:33:44 2011 +0100
committerJan Wielemaker
Fri Mar 25 14:33:44 2011 +0100
commit74e7ce75814d9cdb3caa3f64925f0b631a454a2e
tree397c74d8a677de734e9913db15e20166358b6036
parenteb47dca7391a9becbb23423dc926802d6847abf0
Diff style: patch stat
diff --git a/config-available/xmlrdf.pl b/config-available/xmlrdf.pl
index 96b829c..062f320 100644
--- a/config-available/xmlrdf.pl
+++ b/config-available/xmlrdf.pl
@@ -3,3 +3,10 @@
 /** <module> XML to RDF conversion
 */
 
+:- multifile user:file_search_path/2.
+:- dynamic   user:file_search_path/2.
+
+user:file_search_path(metadata, Dir) :-
+	getenv('RDF_METADATA_DIR', Dir).
+user:file_search_path(metadata, Dir) :-
+	expand_file_name('~/RDF/metadata', [Dir]).
diff --git a/examples/AHM/Notes.txt b/examples/AHM/Notes.txt
index 66ff3a6..970d462 100644
--- a/examples/AHM/Notes.txt
+++ b/examples/AHM/Notes.txt
@@ -1,11 +1,17 @@
-TODO:
-- People thesaurus: use property (Bob)
------------------------------------------------------
+NEW Issues:
+
 
+- ENS: agent in een conceptscheme? nee
+- ENS: map persons properties to RDA Group2 elements
 
 
 
 
+TODO:
+- People thesaurus: use property (Bob)
+- Thesaurus: put in other namespace (purl/vocabularies)?
+- Thesaurus: add skos_inscheme
+-----------------------------------------------------
 
 
 - For the schema file, I have used the old ahm-schema.ttl file, where vra is replaced by dcterms where possible. Here we use the standard vra-dcterms mapping (http://www.vraweb.org/resources/datastandards/vracore3/categories.html#type)
diff --git a/examples/AHM/rewrite.pl b/examples/AHM/rewrite_data.pl
similarity index 88%
rename from examples/AHM/rewrite.pl
rename to examples/AHM/rewrite_data.pl
index 087e58b..7e921d1 100644
--- a/examples/AHM/rewrite.pl
+++ b/examples/AHM/rewrite_data.pl
@@ -43,14 +43,13 @@ list_rules :-
 :- discontiguous
 	rdf_mapping_rule/5.
 
-% URI's are based on ahm:objectnumber as they seem unique \
-%(could also have chosen ahm:priref). Here we only make the
+% URI's are based on ahm:priref as they seem unique  Here we only make the
 % proxy, the rest of the EDM triangle is made later
 
 assign_uris @@
-{ S, ahm:objectNumber, ObjectNumber } \
+{S, ahm:priref, literal(Priref)}\
 { S } <=>
-	literal_to_id(['proxy-', ObjectNumber], ahm, URI),
+	literal_to_id(['proxy-', Priref], ahm, URI),
 	{ URI }.
 
 
@@ -176,13 +175,14 @@ rdf(PersonURI, ahm:name, RC),
 rdf(PersonURI, rdf:type, ahm:'Person'),
 {S, ahm:reproductionCreator, PersonURI}.
 
-% Same for exhibitionOrganiser
+% Same for exhibitionOrganiser, but also include the inverse property
 exhibition_organiser @@
 {S, ahm:exhibitionOrganiser, RC}
 <=>
 rdf(PersonURI, ahm:name, RC),
 rdf(PersonURI, rdf:type, ahm:'Person'),
-{S, ahm:exhibitionOrganiser, PersonURI}.
+{S, ahm:exhibitionOrganiser, PersonURI},
+{PersonURI, ahm:wasPresentAt, S}.
 
 
 
@@ -276,10 +276,10 @@ rdf_is_bnode(B),
 % reconstruct that.
 
 related_object_reference @@
-{S, ahm:relatedObjectReference, literal(ObjRef)}
+{Obj, ahm:objectNumber, ON}\
+{S, ahm:relatedObjectReference, ON}
 <=>
-literal_to_id(['proxy-', ObjRef],ahm, ObjURI),
-	{S,ahm:relatedObjectReference, ObjURI}.
+	{S,ahm:relatedObjectReference, Obj}.
 
 % can be removed if already the title of the thing itself
 related_object_title @@
@@ -407,29 +407,34 @@ true.
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 The following rules replace a literal value by the thesaurus skos
 concept for a given set of properties. Each property uses a separate
-rule. */
+rule.
+We use literal_text to ensure language-typed literals match untyped ones*/
 
 labelPred(skos:prefLabel).
 labelPred(skos:altLabel).
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:acquisitionMethod, literal(Lit)}
 	<=>
 	labelPred(P),
 	{S, ahm:acquisitionMethod, C}.
 
+literal_text(Text, Text) :- atom(Text), !.
+literal_text(lang(_, Text), Text).
+
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:alternativeNumberInstitution, literal(Lit)}
 	<=>
 	labelPred(P),
 	{S, ahm:alternativeNumberInstitution, C}.
+
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:associationSubject, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -437,7 +442,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:contentMotifGeneral, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -445,7 +450,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:contentSubject, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -462,7 +467,7 @@ map_to_thesaurus @@
 % maybe not this one (is always AHM
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:creditLine, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -470,7 +475,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:currentLocation, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -478,15 +483,16 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:currentLocationFitness, literal(Lit)}
 	<=>
 	labelPred(P),
 	{S, ahm:currentLocationFitness, C}.
 
+% no 10
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:dimensionNotes, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -494,7 +500,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:dimensionPart, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -503,7 +509,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:dimensionType, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -519,7 +525,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:documentationTitle, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -527,7 +533,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:exhibitionVenue, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -535,7 +541,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:material, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -543,7 +549,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:objectCategory, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -551,7 +557,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:objectName, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -559,7 +565,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:productionPeriod, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -573,7 +579,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:productionPlace, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -581,7 +587,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:reproductionType, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -589,7 +595,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:technique, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -597,7 +603,7 @@ map_to_thesaurus @@
 
 map_to_thesaurus @@
 {C, rdf:type, skos:'Concept'},
-	{C, P, literal(Lit)}\
+	{C, P, literal(lang(_,Lit))}\
 	{S, ahm:collection, literal(Lit)}
 	<=>
 	labelPred(P),
@@ -625,9 +631,9 @@ with DC attributes for that.
 :- rdf_register_ns(ore,  'http://www.openarchives.org/ore/terms/').
 
 edm @@
-{S, rdf:type, ahm:'Record'},
-{S, ahm:reproduction, Reproduction } ? % reproduction becomes a hasView
-	<=>
+{S, rdf:type, ahm:'Record'}
+%{S, ahm:reproduction, Reproduction } ?
+<=>
 	edm_identifier(S, proxy, aggregation, AggURI),
 	edm_identifier(S, proxy, physical, PhysURI),
 	{ S, rdf:type, ore:'Proxy'},
@@ -636,22 +642,33 @@ edm @@
 	{ S, ore:proxyIn, AggURI },
         { S, ore:proxyFor, PhysURI },
 	{ AggURI, ore:aggregates, PhysURI },
-	{ AggURI, ens:aggregatedCHO, PhysURI },
-	{ AggURI, ens:hasView, Reproduction }.
+	{ AggURI, ens:aggregatedCHO, PhysURI }.
+%	{ AggURI, ahm:reproduction, Reproduction }.
 
 
 % ------------- Thumbnails -------------
 % This guesses the thumbnail uri, based on the object number
-%
+
 get_thumbnails @@
+{ S, rdf:type, ore:'Proxy'},
 {S, ahm:objectNumber, literal(ON)}
 ==>
 	edm_identifier(S, proxy, aggregation, AggURI),
 	object_number_to_url(ON, URL),
-   { AggURI, ens:hasThumbnail, URL },	   % create new property with link to the ens:WebResource
+   { AggURI, ens:object, URL },	   % used to be hasThumbnail
    { URL, rdf:type, ens:'WebResource' }.
 
+% ------------- Landing page  -------------
+% This guesses the landingpage uri, based on the priref
 
+get_landingpage @@
+{ S, rdf:type, ore:'Proxy'},
+{S, ahm:priref, literal(ON)}
+==>
+	edm_identifier(S, proxy, aggregation, AggURI),
+	atom_concat('http://collectie.ahm.nl/dispatcher.aspx?action=detail&database=ChoiceCollect&priref=',ON, URL),
+   { AggURI, ens:landingPage, URL },
+   { URL, rdf:type, ens:'WebResource' }.
 
 
 
diff --git a/examples/AHM/rewrite_people.pl b/examples/AHM/rewrite_people.pl
new file mode 100644
index 0000000..0656b6d
--- /dev/null
+++ b/examples/AHM/rewrite_people.pl
@@ -0,0 +1,62 @@
+:- module(ahm_rewrite_people,
+	  [ rewrite/0,
+	    rewrite/1,
+	    rewrite/2,
+	    list_rules/0
+	  ]).
+:- use_module(library(semweb/rdf_db)).
+:- use_module(library(xmlrdf/rdf_convert_util)).
+:- use_module(library(xmlrdf/cvt_vocabulary)).
+:- use_module(library(xmlrdf/rdf_rewrite)).
+
+:- debug(rdf_rewrite).
+
+%%	rewrite
+%
+%	Apply all rules on the graph =people=
+
+rewrite :-
+	rdf_rewrite(people).
+
+%%	rewrite(+Rule)
+%
+%	Apply the given rule on the graph =people=
+
+rewrite(Rule) :-
+	rdf_rewrite(people, Rule).
+
+%%	rewrite(+Graph, +Rule)
+%
+%	Apply the given rule on the given graph.
+
+rewrite(Graph, Rule) :-
+	rdf_rewrite(Graph, Rule).
+
+%%	list_rules
+%
+%	List the available rules to the console.
+
+list_rules :-
+	rdf_rewrite_rules.
+
+:- discontiguous
+	rdf_mapping_rule/5.
+
+
+people_type @@
+{ A, rdf:type, ahm:'Record' }
+	<=>
+	{ A, rdf:type, ahm:'Person' }.
+
+%VIC: removed this as it forces skos, for now we go with rda
+% {A,skos:inScheme,http://purl.org/collections/nl/am/AM_PeopleScheme'}.
+							%
+
+people_uris @@
+{ A, ahm:name, _Name } \ {A} <=>
+	rdf_is_bnode(A),
+	rdf(A, ahm:priref, literal(Priref)),
+	rdf_current_ns(ahm, S1),
+	concat_atom([S1, 'p-', Priref], S),
+	{S}.
+
diff --git a/examples/AHM/rewrite_thes.pl b/examples/AHM/rewrite_thes.pl
index 877cb85..4822475 100644
--- a/examples/AHM/rewrite_thes.pl
+++ b/examples/AHM/rewrite_thes.pl
@@ -5,9 +5,9 @@
 	    list_rules/0
 	  ]).
 :- use_module(library(semweb/rdf_db)).
-:- use_module(xmlrdf(rdf_convert_util)).
-:- use_module(xmlrdf(cvt_vocabulary)).
-:- use_module(xmlrdf(rdf_rewrite)).
+:- use_module(library(xmlrdf/rdf_convert_util)).
+:- use_module(library(xmlrdf/cvt_vocabulary)).
+:- use_module(library(xmlrdf/rdf_rewrite)).
 :- use_module(util).
 
 :- debug(rdf_rewrite).
@@ -50,7 +50,11 @@ list_rules :-
 record_to_concepts @@
 {S, rdf:type, ahm:'Record'}
 <=>
-{S, rdf:type, skos:'Concept'}.
+{S, rdf:type, skos:'Concept'},
+     %	  rdf_current_ns(ahm, Schema),
+     %	{ S, skos:inScheme, Schema }
+	{ S, skos:inScheme, 'http://purl.org/collections/nl/am/AM_ConceptScheme'}.
+
 
 
 
@@ -69,9 +73,9 @@ rdf(NarUri, ahm:term, NarTerm),
 narrower @@
 {S, ahm:narrowerTerm, NarTerm}
 <=>
-literal_to_id(['t00',NarTerm],ahm, NarUri),
+literal_to_id(['t-new_',NarTerm],ahm, NarUri),
 	{NarUri, rdf:type, skos:'Concept'},
-	{NarUri, skos:prefLabel, NarTerm},
+	{NarUri, skos:prefLabel, NarTerm@nl},
 	{S, skos:narrower, NarUri}.
 
 
@@ -86,9 +90,9 @@ rdf(BroadUri, ahm:term, BroadTerm),
 broader @@
 {S, ahm:broaderTerm, BroTerm}
 <=>
-literal_to_id(['t00',BroTerm],ahm, BroUri),
+literal_to_id(['t-new_',BroTerm],ahm, BroUri),
 	{BroUri, rdf:type, skos:'Concept'},
-	{BroUri, skos:prefLabel, BroTerm},
+	{BroUri, skos:prefLabel, BroTerm@nl},
 	{S, skos:broader, BroUri}.
 
 
@@ -103,9 +107,9 @@ rdf(RelUri, ahm:term, RelTerm),
 related @@
 {S, ahm:relatedTerm,RelTerm}
 <=>
-literal_to_id(['t00',RelTerm],ahm, RelUri),
+literal_to_id(['t-new_',RelTerm],ahm, RelUri),
 	{RelUri, rdf:type, skos:'Concept'},
-	{RelUri, skos:prefLabel, RelTerm},
+	{RelUri, skos:prefLabel, RelTerm@nl},
 	{S, skos:related, RelUri}.
 
 
@@ -163,7 +167,7 @@ termtypes_to_uris @@
 <=>
 rdf_is_bnode(TT),
 not(VAL = literal(lang(_,_))),
-	literal_to_id(['tt00',VAL],ahm,TypeUri),
+	literal_to_id(['t-termtype_',VAL],ahm,TypeUri),
 	{TypeUri}.
 
 termtypes_to_uris @@
@@ -178,7 +182,7 @@ use_to_altlabel @@
  <=>
 rdf(UseUri, ahm:term, UseTerm),
 rdf(S, ahm:term, AltLab),
-	{UseUri, skos:altLabel, AltLab}.
+	{UseUri, skos:altLabel, AltLab@nl}.
 
 use_to_altlabel @@
 {_S, ahm:use, _}
@@ -191,7 +195,7 @@ use_to_altlabel @@
 {S, ahm:usedFor, AltLab}
  <=>
    not(rdf(S, skos:altLabel, AltLab)),
-	{S, skos:altLabel, AltLab}.
+	{S, skos:altLabel, AltLab@nl}.
 
 use_to_altlabel @@
 {_, ahm:usedFor, _}
@@ -208,17 +212,17 @@ use_to_altlabel @@
 term_to_label @@
 {S, ahm:term, Term}
  <=>
-{S, skos:prefLabel, Term}.
+{S, skos:prefLabel, Term@nl}.
 
 
 % ----------- URIs ---------
 
 skos_uris @@
 {S, rdf:type, skos:'Concept'},
-{S, ahm:priref, literal(Pri)},
-{S, skos:prefLabel, literal(Term)} \  {S}
+{S, ahm:priref, literal(Pri)}
+\  {S}
 <=>
-literal_to_id(['t',Pri, Term], ahm, URI),
+literal_to_id(['t-',Pri], ahm, URI),
 {URI}.
 
 
@@ -238,4 +242,11 @@ remove_selected @@
 true.
 
 
+% all things that are type ahm:'Value' can be cleared
+remove_values @@
+{_, rdf:type, ahm:'Value'}
+ <=>
+true.
+
+
 
diff --git a/examples/AHM/run.pl b/examples/AHM/run-data.pl
similarity index 65%
rename from examples/AHM/run.pl
rename to examples/AHM/run-data.pl
index 2838bec..be70dd2 100644
--- a/examples/AHM/run.pl
+++ b/examples/AHM/run-data.pl
@@ -1,35 +1,50 @@
+:- module(ahm_convert_data,
+	  [ run_metadata/0
+	  ]).
+
+user:file_search_path(data,       metadata('AHM')).
+
 :- load_files(library(semweb/rdf_db), [silent(true)]).
 
-:- rdf_register_ns(ahm,	   'http://purl.org/collections/ahm/').
+:- rdf_register_ns(ahm,	   'http://purl.org/collections/nl/am/').
 :- rdf_register_ns(ulan,   'http://e-culture.multimedian.nl/ns/getty/ulan#').
 :- rdf_register_ns(aatned, 'http://e-culture.multimedian.nl/ns/rkd/aatned/').
 
-user:file_search_path(data, '../metadata/AHM').
-
 :- load_files([ cliopatria(cliopatria),
 		library(xmlrdf/xmlrdf),
 		library(semweb/rdf_cache),
 		library(semweb/rdf_library),
 		library(semweb/rdf_turtle_write)
 	      ], [silent(true)]).
-:- use_module(rewrite).
+:- use_module(rewrite_data).
 
 load_ontologies :-
-	rdf_attach_library(cliopatria(rdf)),
-%	rdf_attach_library(getty(.)),
+	rdf_attach_library(cliopatria(ontologies)),
+
 	rdf_load_library(dc),
 	rdf_load_library(skos),
 	rdf_load_library(rdfs),
 	rdf_load_library(owl),
-	absolute_file_name(data('rdf/ahm-schema.ttl'), Schema, [access(read)]),
-	rdf_load(Schema).
+
+	rdf_load(data('rdf/am-schema.ttl'),[graph(am_schema)]),
+	rdf_load(data('rdf/am-people-rdagr2-schema.ttl'),[graph(am_rda_schema)]),
+	rdf_load(data('rdf/am-thesaurus-schema.ttl'),[graph(am_thesaurus_schema)]),
+	rdf_load(data('rdf/ElementsGr2.rdf'),[graph(arda_elementsGr2)]).
+
 
 :- initialization			% run *after* loading this file
+	ensure_dir(cache),
 	rdf_set_cache_options([ global_directory('cache/rdf'),
 				create_global_directory(true)
 			      ]),
 	load_ontologies.
 
+ensure_dir(Dir) :-
+	exists_directory(Dir), !.
+ensure_dir(Dir) :-
+	make_directory(Dir).
+
+
 :- debug(xmlrdf).
 
 load :-
@@ -41,24 +56,14 @@ load :-
 	maplist(load, Files).
 
 load_people_bob:-
-        absolute_file_name(data('rdf/persons.ttl'), File,
-			   [ access(read)
-			   ]),
-	rdf_load(File,[graph(peoplebob)]),
-	absolute_file_name(data('rdf/ahm-people-schema.ttl'), FileSchema,
-			   [ access(read)
-			   ]),
-	rdf_load(FileSchema,[graph(peoplebob_schema)]).
+        absolute_file_name(data('rdf/am-people.ttl'), File,
+			   [ access(read)]),
+	rdf_load(File,[graph(peoplebob)]).
 
 load_thesaurus:-
-        absolute_file_name(data('rdf/thesaurus.ttl'), File,
-			   [ access(read)
-			   ]),
-	rdf_load(File,[graph(thesaurus)]),
-	absolute_file_name(data('rdf/ahm-voc-schema.ttl'), FileSchema,
-			   [ access(read)
-			   ]),
-	rdf_load(FileSchema,[graph(thesaurus_schema)]).
+        absolute_file_name(data('rdf/am-thesaurus.ttl'), File,
+			   [ access(read)]),
+	rdf_load(File,[graph(thesaurus)]).
 
 
 load(File) :-
@@ -99,15 +104,20 @@ sample2 :-
 
 
 save :-
-	absolute_file_name(data('rdf/ahm.ttl'), File,
+	absolute_file_name(data('rdf/am-data.ttl'), File,
 			   [ access(write)
 			   ]),
 	rdf_save_turtle(File, [graph(data)]).
 
-run :-
+run_metadata :-
 	load,
 	load_people_bob,
 	load_thesaurus,
 	rewrite,
 	save.
 
+runsample2:-
+        sample2,
+	load_people_bob,
+	load_thesaurus,
+	rewrite.
diff --git a/examples/AHM/run-people.pl b/examples/AHM/run-people.pl
new file mode 100644
index 0000000..95aefb4
--- /dev/null
+++ b/examples/AHM/run-people.pl
@@ -0,0 +1,73 @@
+:- module(ahm_convert_people,
+	  [ run_people/0
+	  ]).
+
+user:file_search_path(data,       metadata('AHM')).
+
+:- load_files(library(semweb/rdf_db), [silent(true)]).
+
+:- rdf_register_ns(ahm,	   'http://purl.org/collections/nl/am/').
+:- rdf_register_ns(ulan,   'http://e-culture.multimedian.nl/ns/getty/ulan#').
+:- rdf_register_ns(aatned, 'http://e-culture.multimedian.nl/ns/rkd/aatned/').
+:- rdf_register_ns(skos,   'http://www.w3.org/2004/02/skos/core#').
+:- rdf_register_ns(foaf,   'http://xmlns.com/foaf/0.1/').
+
+:- load_files([ cliopatria(cliopatria),
+		library(xmlrdf/xmlrdf),
+		library(semweb/rdf_cache),
+		library(semweb/rdf_library),
+		library(semweb/rdf_turtle_write)
+	      ], [silent(true)]).
+:- use_module(rewrite_people).
+
+load_ontologies :-
+	rdf_attach_library(cliopatria(ontologies)),
+	rdf_load_library(dc),
+	rdf_load_library(skos),
+	rdf_load_library(rdfs),
+	rdf_load_library(owl).
+
+
+:- initialization			% run *after* loading this file
+	ensure_dir(cache),
+	rdf_set_cache_options([ global_directory('cache/rdf'),
+				create_global_directory(true)
+			      ]),
+	load_ontologies.
+
+
+ensure_dir(Dir) :-
+	exists_directory(Dir), !.
+ensure_dir(Dir) :-
+	make_directory(Dir).
+
+
+
+load_people:-
+        absolute_file_name(data('src/people.xml'), File,
+			   [ access(read)
+			   ]),
+	load(File).
+
+load(File) :-
+	rdf_current_ns(ahm, Prefix),
+	load_xml_as_rdf(File,
+			[ dialect(xml),
+			  unit(record),
+			  prefix(Prefix),
+			  graph(people)
+			]).
+
+
+run_people:-
+	load_people,
+	rewrite,
+	rdf_assert(ahm:'AM_PeopleScheme',rdf:type, skos:'ConceptScheme',people),
+	rdf_assert(ahm:'AM_PeopleScheme', rdfs:label, literal('AM People thesaurus'),people),
+	save_thesaurus.
+
+save_thesaurus:-
+	absolute_file_name(data('rdf/am-people.ttl'), File,
+			   [ access(write)
+			   ]),
+	rdf_save_turtle(File,[graph(people)]).
diff --git a/examples/AHM/run-thesaurus.pl b/examples/AHM/run-thesaurus.pl
index 7c2a9fe..2950857 100644
--- a/examples/AHM/run-thesaurus.pl
+++ b/examples/AHM/run-thesaurus.pl
@@ -1,25 +1,21 @@
-:- prolog_load_context(directory, Dir),
-   asserta(user:file_search_path(ahm, Dir)).
+:- module(ahm_thesaurus,
+	  [ run_thesaurus/0
+	  ]).
 
-user:file_search_path(xmlrdf,     ahm('..')).
-user:file_search_path(data,       ahm('../../AHM')).
-user:file_search_path(cliopatria, ahm('../../ClioPatria')).
-user:file_search_path(getty,      ahm('../../../eculture/RDF/vocabularies/getty')).
+user:file_search_path(data,       metadata('AHM')).
 
-:- load_files(library(semweb/rdf_db), [silent(true)]).
+:- use_module(library(semweb/rdf_db)).
 
-:- rdf_register_ns(ahm,	   'http://purl.org/collections/ahm/').
+:- rdf_register_ns(ahm,	   'http://purl.org/collections/nl/am/').
 :- rdf_register_ns(ulan,   'http://e-culture.multimedian.nl/ns/getty/ulan#').
 :- rdf_register_ns(aatned, 'http://e-culture.multimedian.nl/ns/rkd/aatned/').
-:- rdf_register_ns(skos,   'http://www.w3.org/2004/02/skos/core#').
-:- rdf_register_ns(foaf,   'http://xmlns.com/foaf/0.1/').
 
-:- load_files([ cliopatria(cliopatria),
-		xmlrdf(xmlrdf),
+:- use_module([ cliopatria(cliopatria),
+		library(xmlrdf/xmlrdf),
 		library(semweb/rdf_cache),
 		library(semweb/rdf_library),
 		library(semweb/rdf_turtle_write)
-	      ], [silent(true)]).
+	      ]).
 :- use_module(rewrite_thes).
 
 load_ontologies :-
@@ -28,7 +24,7 @@ load_ontologies :-
 	rdf_load_library(skos),
 	rdf_load_library(rdfs),
 	rdf_load_library(owl),
-	absolute_file_name(data('rdf/ahm-voc-schema.ttl'), VocSchema, [access(read)]),
+	absolute_file_name(data('rdf/am-thesaurus-schema.ttl'), VocSchema, [access(read)]),
 	rdf_load(VocSchema,[graph(thesaurus_schema)]).
 
 :- initialization			% run *after* loading this file
@@ -64,11 +60,13 @@ load(File) :-
 
 run_thesaurus:-
 	load_thesaurus,
-	rewrite_thes:rewrite,
+	rewrite,
+	rdf_assert(ahm:'AM_ConceptScheme', rdf:type, skos:'ConceptScheme', thesaurus),
+	rdf_assert(ahm:'AM_ConceptScheme', rdfs:label, literal('AHM thesaurus')),
 	save_thesaurus.
 
 save_thesaurus:-
-	absolute_file_name(data('rdf/thesaurus.ttl'), File,
+	absolute_file_name(data('rdf/am-thesaurus.ttl'), File,
 			   [ access(write)
 			   ]),
 	rdf_save_turtle(File,[graph(thesaurus)]).
diff --git a/examples/AHM/util.pl b/examples/AHM/util.pl
index 6c2caa4..0ab84f8 100644
--- a/examples/AHM/util.pl
+++ b/examples/AHM/util.pl
@@ -9,7 +9,14 @@
 	  ]).
 :- use_module(library(semweb/rdf_db)).
 :- use_module(library(xmlrdf/rdf_convert_util)).
+:- use_module(library(http/http_open)).
+:- use_module(library(http/http_client)).
+:- use_module(library(http/http_cookie)).
 
+:- rdf_register_ns(ahm,	   'http://purl.org/collections/nl/am/').
+:- rdf_register_ns(ens,	   'http://www.europeana.eu/schemas/edm/').
+:- rdf_register_ns(ore,    'http://www.openarchives.org/ore/terms/').
+:- rdf_register_ns(rdf,     'http://www.w3.org/1999/02/22-rdf-syntax-ns#').
 
 % Utility preds that make a creator subproperty based on creator Role.
 % If Role = "", use ahm:maker.
@@ -46,18 +53,19 @@ concat_maybe([A|List],Sep, Literal):-
 	concat_maybe(List,Sep, Literal).
 
 % 'guess' the thumbnail url
-%
 object_number_to_url(ON,URL):-
 	space_to_underscore(ON, ON1),
 	atom_concat('http://ahm.adlibsoft.com/wwwopacx/wwwopac.ashx?command=retrievecontent&imageserver=images&value=',ON1, Almost),
 	atom_concat(Almost,'.jpg',URL).
 
+
 space_to_underscore(In, Out) :-
 	atom_codes(In, CodesIn),
 	maplist(map_space, CodesIn, CodesOut),
 	atom_codes(Out, CodesOut).
 
 map_space(0' , 0'_) :- !.
+map_space(0'., 0'_) :- !.
 map_space(C, C).
 
 
@@ -66,3 +74,55 @@ map_space(C, C).
 lang_to_langcode('0',en).
 lang_to_langcode('1',nl).
 lang_to_langcode('3',de).
+
+
+
+
+% Image checker
+%
+%
+lp1('http://collectie.ahm.nl/dispatcher.aspx?action=detail&database=ChoiceCollect&priref=14233').
+lp2('http://collectie.ahm.nl/dispatcher.aspx?action=detail&database=ChoiceCollect&priref=14234').
+
+check_all_img:-
+	findall(Agg-LP, rdf(Agg, ens:landingPage, LP),List),
+	assert(todolist(List)),
+	forall(member(A-LP,List), (check_img(A-LP),sleep(2))).
+
+check_img(A-LP):-
+	remove_existing(A),
+	(   get_img_from_lp(LP, Image) ->
+	    (   rdf_assert(A, ens:object, Image),
+	        rdf_assert(Image, rdf:type, ens:'WebResource')
+	    );
+	    true),
+	format('\tdone ~w\n',[A]).
+
+remove_existing(A):-
+	rdf(A, ens:object, WR),
+	rdf_retractall(A, ens:object, WR),
+	rdf_retractall(WR, rdf:type, _).
+remove_existing(_).
+
+
+get_img_from_lp(LandingURL, ImageURL):-
+	http_open(LandingURL, S, []),
+	load_html(S, Term),
+	sub_term(element(img, Attr, _), Term),
+	member(class=detailImage,Attr),
+	member(src=ImageURL, Attr),
+	close(S).
+
+load_html(URL, DOM) :-
+       setup_call_cleanup(http_open(URL, In, []),
+                          (   dtd(html, DTD),
+                              load_structure(stream(In),
+                                             DOM,
+                                             [ dtd(DTD),
+                                               dialect(sgml),
+                                               shorttag(false),
+                                               syntax_errors(quiet)
+                                             ])
+                          ),
+                          close(In)).
+
diff --git a/lib/xmlrdf/xmlrdf.pl b/lib/xmlrdf/xmlrdf.pl
index 57b0077..56949fd 100644
--- a/lib/xmlrdf/xmlrdf.pl
+++ b/lib/xmlrdf/xmlrdf.pl
@@ -46,8 +46,8 @@
 :- use_module(library(record)).
 :- use_module(library(apply)).
 
-:- use_module(config_available(skos)).
-:- use_module(config_available(foaf)).
+:- use_module(library(skos_schema)).
+:- use_module(library(foaf_schema)).
 
 :- rdf_register_ns(map, 'http://cs.vu.nl/eculture/map/').