-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmap.dist
executable file
·69 lines (66 loc) · 2.5 KB
/
map.dist
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
#!/bin/bash
set -e
SUBS="Bahmni Bb GnuHealth Orthanc Standard WhoDhiClient WhoDhiDataService WhoDhiHealthcareProvider WhoDhiHealthSystemManager WhoDhiSystemCategory EhrSfm Mb Link"
TEMPLATES="attribute standard subfeature feature function applicationsystemtype applicationsystemtypecitation featurecitation functioncitation organizationalunitcitation usergroupcitation link"
RED='\033[0;31m'
ORANGE='\033[0;33m'
LIGHTGREEN='\033[1;32m'
GRAY='\033[0;37m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
NC='\033[0m'
function map
{
echo -e "* ${BLUE}DIRECTORY ${s}${NC}"
mkdir -p ${s}/tmp
mkdir -p ${s}/tmp/old
mv ${s}/tmp/*.nt ${s}/tmp/old || true
found=0
for t in $TEMPLATES
do
csv="${s}/${t}.csv"
if [ -e $csv ]
then
echo -e -n "** ${LIGHTGREEN}Using Template ${t} on ${csv} ${NC}..."
((found=found+1))
mkdir -p ${s}/out
sed "s|{SUB}|${s}|g" ${t}.tarql.template > ${s}/tmp/${t}.tarql
tarql ${s}/tmp/${t}.tarql | rapper -q -i turtle - http://hitontology.eu/ontology/ > ${s}/tmp/${t}.nt
echo -e " ${LIGHTGREEN}`wc -l < ${s}/tmp/${t}.nt` triples${NC}"
#else
#echo -e "${GRAY}**** ${csv} DOES NOT EXIST, SKIPPING TEMPLATE ${t} *******************************${NC}"
fi
done
if [ $found -eq "0" ]
then
echo -e "** ${RED}ERROR: DIRECTORY ${s} DOES NOT MATCH ANY TEMPLATE, SKIPPING ${s} ${NC}"
return
fi
echo -e -n "** ${LIGHTGREEN}Merging${NC}... "
if [ -e ${s}/base.ttl ]
then
echo -e -n "$LIGHTGREEN adding base${NC}: "
rapper -q -i turtle ${s}/base.ttl > ${s}/tmp/base.nt
echo -e -n "$LIGHTGREEN `wc -l < ${s}/tmp/base.nt` triples${NC}. "
fi
cat prefix.ttl ${s}/tmp/*.nt | rapper -q -i turtle -o turtle - http://hitontology.eu/ontology/ > ${s}/out/all.ttl
rapper -q -i turtle -o ntriples ${s}/out/all.ttl >> /tmp/combined.nt
echo -e -n "${LIGHTGREEN}Testing${NC}... "
rapper -q -i turtle -c ${s}/out/all.ttl
echo -e "${LIGHTGREEN}`wc -l < ${s}/out/all.ttl` triples in ${s}/out/all.ttl, `wc -l < /tmp/combined.nt` total${NC}"
}
rm -f /tmp/combined.nt
for s in $SUBS
do
if [ ! -d "${s}" ]
then
echo -e "** ${RED}ERROR: DIRECTORY ${s} DOES NOT EXIST, SKIPPING ${s} ${NC}"
else
map $s # no fork needed, tarql is parallized already
fi
done
echo -e -n "${LIGHTGREEN}sorting and converting to Turtle format${NC}... "
sort /tmp/combined.nt -o /tmp/combined.nt
rapper -q -i turtle -c /tmp/combined.nt
cat prefix.ttl /tmp/combined.nt | rapper -q -i turtle -o turtle - http://hitontology.eu/ontology/ > /tmp/combined.ttl
echo -e "${LIGHTGREEN}`wc -l < /tmp/combined.nt` triples in /tmp/combined.ttl${NC}"