-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·84 lines (73 loc) · 1.56 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·84 lines (73 loc) · 1.56 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
infile=`awk 'BEGIN{FS=","} { confs[$1]=$2 } END { print confs["input"] }' config.csv`
outfile=`awk 'BEGIN{FS=","} { confs[$1]=$2 } END { print confs["output"] }' config.csv`
declare -A itemCodes
declare -A itemCodesReverse
eval "itemCodes=($(awk 'BEGIN{FS=","
cnt=0}
{
for(i=1;i<=NF;i++) {
if(itemCodes[$i]<1) {
cnt++
itemCodes[$i]=cnt
}
}
}
END {
for(item in itemCodes)
print "[\"" item "\"]=" "\"" itemCodes[item] "\""
}' $infile) )"
eval "itemCodesReverse=($(awk 'BEGIN{FS=","
cnt=0}
{
for(i=1;i<=NF;i++) {
if(itemCodes[$i]<1) {
cnt++
itemCodes[$i]=cnt
}
}
}
END {
for(item in itemCodes)
print "[\"" itemCodes[item] "\"]=" "\"" item "\""
}' $infile) )"
OIFS=IFS
IFS=","
while read line
do
record=($line)
len=${#record[@]}
for((i=0;i<$len-1;i++))
do
printf '%s,' ${itemCodes[${record[$i]}]}
done
printf '%s\n' ${itemCodes[${record[$i]}]}
done < $infile > converted.csv
IFS=OIFS
./apriori
OIFS=IFS
IFS=","
while read line
do
record=($line)
len=${#record[@]}
for((i=0;i<$len-1;i++))
do
if [ "${record[$i]}" != "=>" ] && [ "${record[0]}" != "#" ]
then
printf '%s,' ${itemCodesReverse[${record[$i]}]}
elif [ "${record[0]}" != "#" ]
then
printf "=>,"
else
printf '%s\n' "${record[1]}"
fi
done
if [ "${record[0]}" != "#" ]
then
printf '%s\n' ${itemCodesReverse[${record[$i]}]}
fi
done < tempOutput.csv > $outfile
IFS=OIFS
rm -rf converted.csv
rm -rf tempOutput.csv
rm -rf tempRuleOutput.csv