-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathold-fix-graph.sh
71 lines (52 loc) · 2.19 KB
/
old-fix-graph.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
68
69
70
71
## [WNLITE.NT]
## copy wnlite unmodified
cp new-namespace/wnlite.nt clean/
## [WORDNET-EN.NT]
## copy wordnet-en unmodified
cp new-namespace/wordnet-en.nt clean/
## [NOMLEX.NT]
## copy nomlex unmodified
cat new-namespace/nomlex.nt > clean/own-pt.nt
## [DEFAULT-GRAPH.NT]
## split into a couple of sub-components
grep '^<http://logics.emap.fgv.br/wn/>' new-namespace/default-graph.nt > tmp/1
grep -v '^<http://logics.emap.fgv.br/wn/>' new-namespace/default-graph.nt > tmp/not-1
grep '^<https://w3id.org/own-pt/nomlex/' tmp/not-1 > tmp/2
grep -v '^<https://w3id.org/own-pt/nomlex/' tmp/not-1 > tmp/not-2
grep '^<https://w3id.org/own-pt/wn30-en/' tmp/not-2 > tmp/3
grep -v '^<https://w3id.org/own-pt/wn30-en/' tmp/not-2 > tmp/not-3
grep '^<https://w3id.org/own-pt/wn30-pt/' tmp/not-3 > tmp/4
grep -v '^<https://w3id.org/own-pt/wn30-pt/' tmp/not-3 > tmp/not-4
grep '^<https://w3id.org/own-pt/wn30/schema/' tmp/not-4 > tmp/5
grep -v '^<https://w3id.org/own-pt/wn30/schema/' tmp/not-4 > tmp/not-5
grep '^<http://wordnet.princeton.edu/' tmp/not-5 > tmp/6
grep -v '^<http://wordnet.princeton.edu/' tmp/not-5 > tmp/not-6
if [ `wc -l tmp/? | grep total | awk '{print $1}'` != `wc -l new-namespace/default-graph.nt | awk '{print $1}'` ]
then
echo "Error extracting different components from DEFAULT-GRAPH. Aborting."
exit 1;
else
echo "DEFAULT-GRAPH extraction successful. Continuing."
fi
cat tmp/1 >> clean/own-pt.nt
cat tmp/2 >> clean/own-pt.nt
cat tmp/3 >> clean/wordnet-en.nt
cat tmp/4 >> clean/own-pt.nt
cat tmp/5 >> clean/suffixes.nt
cat tmp/6 >> clean/wordnet-en.nt
## [OWN-PT]
## all the sameAs predicates are in own-pt.nt, move them to another
## file and keep a temporary version that doesn't have them
fgrep 'http://www.w3.org/2002/07/owl#sameAs' new-namespace/own-pt.nt > clean/same-as.nt
## the remainder of own-pt can be copied as-is, provided that it does
## not carry any blank node!
fgrep -v 'http://www.w3.org/2002/07/owl#sameAs' new-namespace/own-pt.nt >> tmp/own-pt.nt
if fgrep -q '_:' tmp/own-pt.nt
then
echo "Blank nodes found in new-namespace/own-pt.nt. Aborting."
exit 1
fi
cat tmp/own-pt.nt >> clean/own-pt.nt
wc new-namespace/*
wc clean/*
echo "Now, import the files into Allegro Graph."