-
Notifications
You must be signed in to change notification settings - Fork 2
/
create-repo-posneg-core.sh
executable file
·56 lines (39 loc) · 1.32 KB
/
create-repo-posneg-core.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
#!/bin/bash
#outBase="repo-posneg"
source config
outBase=$1
if [ -z "$outBase" ]; then
echo "Please specify the directory for the output directory"
exit -1
fi
minPosTripleCount=${2:-50}
minNegTripleCount=${3:-$minPosTripleCount}
echo "minPosTripleCount: $minPosTripleCount"
echo "minNegTripleCount: $minNegTripleCount"
for dir in `find "$latcRepo" -type d`; do
specFile="$dir/spec.xml"
posFile="$dir/positive.nt"
negFile="$dir/negative.nt"
if [ -f "$specFile" -a -f "$posFile" -a -f "$negFile" ]; then
d="${dir##/*/}"
echo "Candidate: $d"
tmpEndpointFile="/tmp/endpoints.txt"
tmpPosFile="/tmp/positive.nt"
tmpNegFile="/tmp/negative.nt"
./extract-endpoints.sh "$specFile" > "$tmpEndpointFile"
cat "$posFile" | awk 1 | rapper -i ntriples - http://dummy.org | sort -u > "$tmpPosFile"
cat "$negFile" | awk 1 | rapper -i ntriples - http://dummy.org | sort -u > "$tmpNegFile"
posTripleCount=`cat "$tmpPosFile" | wc -l`
negTripleCount=`cat "$tmpNegFile" | wc -l`
if [ "$posTripleCount" -lt "$minPosTripleCount" -o "$negTripleCount" -lt "$minNegTripleCount" ]; then
echo "Skip: $d"
continue;
fi
echo "Accept: $d"
targetDir="$outBase/$d"
mkdir -p "$targetDir"
mv "$tmpEndpointFile" "$targetDir"
mv "$tmpPosFile" "$targetDir"
mv "$tmpNegFile" "$targetDir"
fi
done