-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_java_map_from_csv.sh
executable file
·67 lines (53 loc) · 1.54 KB
/
generate_java_map_from_csv.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
#!/bin/bash
TARGETFOLDER=olia.nlp2rdf.org/owl
find $TARGETFOLDER -name "*.java" | xargs rm
java_name()
{
NICENAME=$(echo "$1" | sed 's/-/_/g;s/\./_/g;s/0/Zero/g;s/One/b/g;s/2/Two/g;s/3/Three/g;s/4/Four/g;s/5/Five/g;s/6/Six/g;s/7/Seven/g;s/8/Eight/g;s/9/Nine/g;' )
NICENAME=${NICENAME^};
echo $NICENAME
}
transform_linkingmodel_to_java()
{
FILE="$1""-link.rdf.csv"
if [ -s $FILE ]
then
echo " public static MultiValueMap links = MultiValueMap.decorate(new HashMap<String, ArrayList<String>>());
static {
"
sed "s/\t/\", \"/;s/^/\t\tlinks.put(\"/;s/$/\");/" $FILE
echo " }
"
fi
}
transform_annotationmodel_to_java()
{
FILE="$1"".owl.csv"
if [ -s $FILE ]
then
#treatment of hasTag
echo " public static MultiValueMap hasTag = MultiValueMap.decorate(new HashMap<String, ArrayList<String>>());
static {
"
grep 'hasTag$' $FILE | cut -f1,2 | sed "s/\t/\", \"/;s/^/\t\thasTag.put(\"/;s/$/\");/"
echo " }
"
fi
}
for FILE in `find $TARGETFOLDER -name "*-link.rdf" `
do
#s/.*\///;
PLAINNAME=$(echo "$FILE" | sed 's/-link.rdf$//;s/.*\///;' )
JAVANAME=$(java_name $PLAINNAME)
echo "package org.nlp2rdf.vocabularymodule.olia;
import org.apache.commons.collections.map.MultiValueMap;
import java.util.ArrayList;
import java.util.HashMap;
public class $JAVANAME {
" > $TARGETFOLDER/$JAVANAME.java
transform_linkingmodel_to_java $TARGETFOLDER/$PLAINNAME >> $TARGETFOLDER/$JAVANAME.java
transform_annotationmodel_to_java $TARGETFOLDER/$PLAINNAME >> $TARGETFOLDER/$JAVANAME.java
echo "
}
" >> $TARGETFOLDER/$JAVANAME.java
done