87N/ABASE = ..
87N/APUB_SYNCFILES = registry-expanded.turtle registry.rdf registry.turtle README
87N/AWORK_SYNCFILES =
87N/ASYNCDIRS =
87N/A
87N/ADEPLOY_FILES = registry.rdf registry-expanded.rdf $(DEPLOY_DIR)/logics/CommonLogic/index
87N/AEXPANDED_DATASET = registry-expanded.ntriples
87N/ADOL_INFERENCES = $(LIB)/dol-inferences-beyond-owl.n3
87N/AOWL_INFERENCES = $(LIB)/some-owl-inferences.n3
87N/ADOL_RDF_VOCAB = ../syntax/dol-rdf.owl
87N/ASTANDARD_VOCAB = ../syntax/standardization.owl
87N/ATODO_VOCAB = ../syntax/todo.owl
87N/AEYEBALL_FIXES = eyeball-fixes.rdf # some things eyeball reports missing, even though they actually exist
87N/AREGISTRY_NS = http://purl.net/dol/
87N/AEYEBALL_DEFAULT_ARGS = -assume $(DOL_RDF_VOCAB) -assume $(STANDARD_VOCAB) -assume $(TODO_VOCAB) -assume $(DCTERMS) -assume $(SKOS) -assume $(OWL) -assume $(EYEBALL_FIXES)
87N/A
87N/Ainclude $(BASE)/Makefile.vars
87N/Ainclude $(BASE)/Makefile.in
87N/Ainclude Makefile.vars
87N/Ainclude ../syntax/Makefile.in
87N/A
87N/Aall: $(DEPLOY_FILES)
87N/A
87N/A# Eyeball must be last, as it usually fails
87N/Atest: registry-with-tbox.rdf registry.eyeball
87N/A
87N/A# validate RDF with Eyeball
87N/A%.eyeball: %.rdf
87N/A eyeball $(EYEBALL_DEFAULT_ARGS) -check $<
87N/A
87N/A# Registry TBox (the OWL ontology that defines the vocabulary of the graph) and ABox (the actual graph) combined, for the purpose of validating (manually, known to work with HermiT in Protégé 4.1) whether the ABox is consistent wrt. the TBox.
87N/Aregistry-with-tbox.rdf: registry-expanded.ntriples
87N/A cwm --n3 $< --rdf $(DOL_RDF_VOCAB) > $@
87N/A
87N/A# 1. apply the N3 ruleset to expand the core dataset to the expanded dataset; in detail:
87N/A# cwm --n3 $< # parse the input as N3 (a superset of Turtle)
87N/A# --rdf $(BASE)/syntax/dol-rdf.owl # parse the ontology as RDF/XML
456N/A# --n3 $(DOL_INFERENCES) # load DOL-specific inference rules (particularly those that can't be represented in OWL, but only in FOL)
140N/A# $(OWL_INFERENCES) # load general OWL (and RDFS and RDF) inference rules (just a relevant subset of the actual rules, implemented ad hoc according to our needs)
140N/A# --think # apply the inference rules until they lead to no more expansions
140N/A# --ntriples # create N-Triples output for easy linewise post-processing
140N/A# $(CWM_DEFAULT_ARGS)
140N/A# 2. remove leading whilespace
87N/A# 3. filter out any triples whose subjects are not from the namespace of this dataset. This includes blank nodes, which are just used for editorial comments so far
87N/A# 4. filter out triples containing blank nodes in any component. Many blank nodes are not relevant for the dataset (e.g. artifacts from the RDF serialization of the OWL ontology, editorial comments, etc.), and those, that are, are not supported by our approach.
87N/A# 5. filter out triples with certain annotation properties (here: editorial comments)
87N/A%-expanded.ntriples: %.turtle $(DOL_INFERENCES) $(OWL_INFERENCES)
91N/A cwm --n3 $< --rdf $(BASE)/syntax/dol-rdf.owl --n3 $(DOL_INFERENCES) $(OWL_INFERENCES) --think --ntriples $(CWM_DEFAULT_ARGS) \
91N/A | perl -pe 's/^[[:space:]]*//' \
87N/A | grep '^<http://purl\.net/dol/' \
87N/A | grep -v '^<http://purl\.net/dol/1\.0/rdf#' \
91N/A | grep -vE '^<[^>]+>[^<]+(_:|<http://example\.org/todo#)' \
91N/A > $@
91N/A
91N/A# convert expanded N-Triples datasets to Turtle
91N/A%-expanded.turtle: %-expanded.ntriples
87N/A cwm --n3=tv $< > $@
87N/A
87N/A# Output all distinct subject URIs (and blank node IDs) that occur in the dataset.
87N/A# Omit any namespaces we are not interested in deploying.
87N/Aresource-uris: $(EXPANDED_DATASET)
87N/A awk '{print gensub("<([^>]+)>", "\\1", 1, $$1)}' $< \
91N/A | sort \
91N/A | uniq \
87N/A > $@
87N/A
91N/A# Make sure that all directories exist in whose paths we have resources.
91N/A# We use one directory path as a representative for generating all of them.
91N/A$(DEPLOY_DIR)/logics: resource-uris
91N/A perl -lne 'print $$1 if m@^http://purl\.net/dol/((?:[^/]+/)*)[^/]+@' $< \
91N/A | sort \
87N/A | uniq \
87N/A | while read directory ; do \
87N/A echo $$directory ; \
168N/A target=$(DEPLOY_DIR)/$$directory ; \
168N/A $(MKDIR) $$target ; \
168N/A cp .htaccess $$target ; \
168N/A done
168N/A
168N/A# Use the URI of one resource as a representative for generating all split files
168N/A# For each resource, …
168N/A# 1. read all triples having this resource as a subject
168N/A# 2. output them to a self-contained RDF/XML file named after the resource
168N/A$(DEPLOY_DIR)/logics/CommonLogic/index: resource-uris $(DEPLOY_DIR)/logics
168N/A function do_split() { \
168N/A resource_pattern=$$1 ; \
168N/A main_resource=$$2 ; \
168N/A out_file=$(DEPLOY_DIR)/$${main_resource#$(REGISTRY_NS)} ; \
87N/A if [[ -d $$out_file ]]; then out_file=$${out_file}/index; fi ; \
87N/A grep "$${resource_pattern}" $(EXPANDED_DATASET) \
87N/A | cwm --n3 --rdf $(CWM_DEFAULT_ARGS) \
87N/A > $$out_file ; \
87N/A } ; \
87N/A while read resource ; do \
87N/A echo $$resource ; \
87N/A do_split "^<$$resource>" $$resource ; \
87N/A done < $< ; \
87N/A
87N/A.PHONY: all test
87N/A