forked from adrianjav/heterogeneous_vaes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_types.sh
executable file
·67 lines (58 loc) · 1.41 KB
/
read_types.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
#!/bin/bash
echo -n "{'probabilistic model': ['"
first=true
for line in $( tr '\r' '\n' < "$1" | tail -n +2 | cut -d, -f 1,2); do
type=$(echo $line | cut -d, -f 1)
dim=$(echo $line | cut -d, -f 2)
if ! $first ; then
echo -n "', '"
fi
first=false
if [ "$type" = "pos" ] ; then
echo -n "lognormal"
elif [ "$type" = "real" ] ; then
echo -n "normal"
elif [[ "$type" = "cat" ]] || [[ "$type" = "ordinal" ]]; then
if [ "$dim" = "2" ] ; then
echo -n "bernoulli"
if [ "$2" = "--gamma-trick" ] ; then
echo -n "*"
fi
else
echo -n "categorical($dim)"
if [[ "$2" = "--gamma-trick" ]] ; then
echo -n "*"
elif [[ "$2" = "--bern-trick" ]] ; then
echo -n "+"
fi
fi
elif [ "$type" = "count" ] ; then
echo -n "poisson"
if [ "$2" = "--gamma-trick" ] ; then
echo -n "*"
fi
fi
done
echo -n "'], "
first=true
count=0
echo -n "'categoricals': ["
for line in $( tr '\r' '\n' < "$1" | tail -n +2 | cut -d, -f 1,2); do
type=$(echo $line | cut -d, -f 1)
dim=$(echo $line | cut -d, -f 2)
if [[ "$type" = "cat" ]] || [[ "$type" = "ordinal" ]]; then
if ! $first ; then
echo -n ", "
fi
first=false
echo -n "$count"
elif [ "$type" = "ordinal" ] ; then
if ! $first ; then
echo -n ", "
fi
first=false
echo -n "$count"
fi
count=$((count+1))
done
echo "]}"