Skip to content

Commit 094dc2d

Browse files
author
Daniel
committed
get distinct properties of NELL
1 parent 30bfb95 commit 094dc2d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

NELL/getAllProperties.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
nell = '../../../SeminarPaper_KG_Files/NELL/NELL.08m.995.esv.csv'
2+
ontology = '../../../SeminarPaper_KG_Files/NELL/NELL.08m.995.ontology.csv'
3+
readFiles = [nell]#], ontology]
4+
propertySet = set()
5+
6+
def getP(splittedLine):
7+
word_position = 0
8+
for word in splittedLine:
9+
if (word_position == 1):
10+
pred = word
11+
word_position += 1
12+
return pred
13+
14+
def getSPO(splittedLine):
15+
word_position = 0
16+
for word in splittedLine:
17+
if (word_position == 0):
18+
subj = word
19+
elif (word_position == 1):
20+
pred = word
21+
elif (word_position == 2):
22+
obj = word
23+
else:
24+
return subj, pred, obj
25+
word_position += 1
26+
return subj, pred, obj
27+
28+
29+
for file in readFiles:
30+
f = open(file, 'r')
31+
for line in f:
32+
splittedLine = line.rstrip('\n').split()
33+
s, p, o = getSPO(splittedLine)
34+
if p not in propertySet:
35+
propertySet.add(p)
36+
if (p == 'generalizations'):
37+
print o
38+
f.close()
39+
40+
#print propertySet

0 commit comments

Comments
 (0)