forked from OPEN-NEXT/OKH-LOSH
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualize
More file actions
executable file
·136 lines (118 loc) · 2.99 KB
/
visualize
File metadata and controls
executable file
·136 lines (118 loc) · 2.99 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
set -e
_install_req() {
if ! ( which wget > /dev/null && which pip > /dev/null && which javac > /dev/null )
then
apt-get update
apt-get install -y -qq wget python3-pip default-jdk > /dev/null
fi
wget https://gitlab.com/OSEGermany/rdf-visualizer/raw/master/visualize-rdf
chmod +x ./visualize-rdf
./visualize-rdf --install-requirements
wget https://osegermany.gitlab.io/oh-tsdc-tools/tsdc-tools-latest-jar-with-dependencies.jar
}
if [ ! -f ./visualize-rdf ]
then
_install_req
fi
mkdir -p build
# Create (visual) graphs
echo
for ttl_file in *.ttl
do
./visualize-rdf --do-not-open --layout fdp "$ttl_file"
done
for file in *.svg *.png
do
mv "$file" "fdp_${file}.RN"
done
echo
for ttl_file in *.ttl
do
./visualize-rdf --do-not-open --layout dot "$ttl_file"
done
for file in *.svg *.png
do
mv "$file" "dot_${file}.RN"
done
for file in *.RN
do
mv "$file" "${file%.RN}"
done
echo
for dot_file in *.dot
do
layout_engine=fdp
dot_file_clean="build/${dot_file%.dot}-clean.dot"
echo "Cleaning '$dot_file' -> '$dot_file_clean' ..."
{
grep -v 'wikidata' \
| grep -v ':base' \
| grep -v 'ObjectProperty' \
| grep -v 'DatatypeProperty' \
| grep -v 'Class' \
| grep -v 'Ontology'
} < "$dot_file" > "$dot_file_clean"
svg_file="${dot_file_clean%.dot}.svg"
png_file="${dot_file_clean%.dot}.png"
echo "Generating SVG and PNG from '$dot_file_clean' ..."
dot -Glayout="$layout_engine" -Grankdir=LR -Tsvg -o "$svg_file" "$dot_file_clean"
dot -Glayout="$layout_engine" -Grankdir=LR -Tpng -o "$png_file" "$dot_file_clean"
done
mv ./*.dot ./*.svg ./*.png build/
# Create structured Markdown
echo
for ttl_file in *.ttl
do
java \
-classpath tsdc-tools-latest-jar-with-dependencies.jar \
de.opensourceecology.tsdc.tools.rdf2md.MainKt \
--input "$ttl_file" \
--output "build/${ttl_file}.md"
# --structure-property "http://purl.org/oseg/din/ontologies/tsdc/0.1/specification#isBelow" \
done
cd build
{
# Create HTML that links to all the files generated above
# plus the sources
echo "<html>"
echo "<head>"
echo "<title>Sources & Generated output</title>"
echo "</head>"
echo "<body>"
echo "<h1>Sources & Generated output</h1>"
echo "<h3>Turtle/RDF sources</h3>"
echo "<ul>"
for file in *.ttl
do
echo "<li><a href=\"$file\">$file</a></li>"
done
echo "</ul>"
echo "<h3>Markdown files laying out the structure</h3>"
echo "<ul>"
for file in *.md
do
echo "<li><a href=\"$file\">$file</a></li>"
done
echo "</ul>"
echo "<h3>GraphViz/DOT graps representing the structure</h3>"
echo "<ul>"
for file in *.dot
do
echo "<li><a href=\"$file\">$file</a></li>"
done
echo "</ul>"
echo "<h3>PNG & SVG renders of the above graphs</h3>"
echo "<ul>"
for file in *.svg
do
file_png="${file%.svg}.png"
echo "<li>"
echo "<a href=\"$file\">$file - <img src=\"$file\" alt=\"$file\" width=\"640\"/></a> - "
echo "<a href=\"$file_png\">$file_png - <img src=\"$file_png\" alt=\"$file\" width=\"640\"/></a>"
echo "</li>"
done
echo "</ul>"
echo "</body>"
echo "</html>"
} > index.html