-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfn_stats.py
More file actions
executable file
·59 lines (45 loc) · 2.01 KB
/
fn_stats.py
File metadata and controls
executable file
·59 lines (45 loc) · 2.01 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
#!/usr/bin/env python
from KafNafParserPy import *
from rdflib import URIRef, Namespace
from rdflib.namespace import RDF,Namespace, NamespaceManager
from rdflib.graph import Graph
import sys
import os
path='example'
predicates_pos_fn = 0
predicates_neg_fn = 0
predicates_fn_total=0
roles_pos_fn = 0
roles_neg_fn = 0
roles_fn_total=0
for root, dirs, files in os.walk(path):
for inputfile in files:
try:
# Parse using the KafNafParser
my_parser = KafNafParser(root + "/" + inputfile)
except:
continue
# Iterate over the predicates and check for ESO predicates in the external references
for predicate in my_parser.get_predicates():
for ext_ref in predicate.get_external_references():
if ext_ref.get_resource()=='FrameNet+':
predicates_pos_fn+=1
elif ext_ref.get_resource()=='FrameNet-':
predicates_neg_fn+=1
elif ext_ref.get_resource()=='FrameNet':
predicates_fn_total+=1
# When there is an ESO choice, iterate through the roles and identify the right FrameNet meanings there as well
for role in predicate.get_roles():
for role_ext_ref in role.get_external_references():
if role_ext_ref.get_resource()=='FrameNet+':
roles_pos_fn+=1
elif role_ext_ref.get_resource()=='FrameNet-':
roles_neg_fn+=1
elif role_ext_ref.get_resource()=='FrameNet':
roles_fn_total+=1
print "Positive FrameNet predicates: " + str(predicates_pos_fn)
print "Negative FrameNet predicates:" + str(predicates_neg_fn)
print "Unjudged FrameNet predicates: " + str(predicates_fn_total)
print "Positive FrameNet roles: " + str(roles_pos_fn)
print "Negative FrameNet roles:" + str(roles_neg_fn)
print "Unjudged FrameNet roles: " + str(roles_fn_total)