forked from edmcouncil/fibo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-about.sh
87 lines (68 loc) · 2.42 KB
/
build-about.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#
# Create an about file in RDF/XML format, do this BEFORE we convert all .rdf files to the other
# formats so that this about file will also be converted.
#
# TODO: Generate this at each directory level in the tree
# I don't think this is correct; the About files at lower levels have curated metadata in them. -DA
#
# DONE: Should be done for each serialization format
#
function ontologyCreateAboutFiles () {
local tmpAboutFileDev="$(mktemp ${tmp_dir}/ABOUTD.XXXXXX.ttl)"
local tmpAboutFileProd="$(mktemp ${tmp_dir}/ABOUTP.XXXXXX.ttl)"
local echoq="$(mktemp ${tmp_dir}/echo.sparqlXXXXXX)"
(
cd ${tag_root}
cat > "${tmpAboutFileProd}" << __HERE__
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix owl: <http://www.w3.org/2002/07/owl#>
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
<${tag_root_url}/AboutFIBO> a owl:Ontology;
__HERE__
grep \
-r 'utl-av[:;.]Release' . | \
grep -F ".rdf" | \
sed 's/:.*$//' | \
while read file; do
grep "xml:base" "${file}";
done | \
sed 's/^.*xml:base="/owl:imports </;s/"[\t \n\r]*$/> ;/' \
>> "${tmpAboutFileProd}"
cat > "${echoq}" << __HERE__
CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o}
__HERE__
"${jena_arq}" --data="${tmpAboutFileProd}" --query="${echoq}" --results=RDF > AboutFIBOProd.rdf 2>${tmp_dir}/err.tmp
if [ -s ${tmp_dir}/err.tmp ]
then echo "no RDF XML output generated. Use AboutFIBOProd.ttl file instead"
fi
)
(
cd ${tag_root}
cat > "${tmpAboutFileDev}" << __HERE__
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@prefix owl: <http://www.w3.org/2002/07/owl#>
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
<${tag_root_url}/AboutFIBO> a owl:Ontology;
__HERE__
grep \
-r "xml:base" \
$( \
find . -mindepth 1 -maxdepth 1 -type d -print | \
grep -vE "(etc)|(git)"
) | \
grep -vE "(catalog)|(About)|(About)" | \
sed 's/^.*xml:base="/owl:imports </;s/"[ \n\r]*$/> ;/' \
>> "${tmpAboutFileDev}"
cat > "${echoq}" << __HERE__
CONSTRUCT {?s ?p ?o} WHERE {?s ?p ?o}
__HERE__
"${jena_arq}" --data="${tmpAboutFileDev}" --query="${echoq}" --results=RDF > AboutFIBODev.rdf 2>${tmp_dir}/err.tmp
if [ -s ${tmp_dir}/err.tmp ]
then echo "no RDF XML output generated. Use AboutFIBODev.ttl file instead"
fi
)
return 0
}