-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperformance.py
19 lines (18 loc) · 941 Bytes
/
performance.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#how many words in dictionary have examples
def performance(lexicon, corpus):
entries_w_exe = [0, 0]
exes_matching_lex = 0
flag = False
used_exes = []
for entry in lexicon:
for i in range(len(corpus)):
if entry in corpus[i]:
exes_matching_lex += 1
if i not in used_exes: used_exes.append(i)
if not flag:
flag = True
entries_w_exe[0] += 1
if not flag: entries_w_exe[1] += 1
print("Percentage of lexicon entries with an example:", 100*round(entries_w_exe[0]/(entries_w_exe[0]+entries_w_exe[1]), 3))
print("Average number of examples per lexicon entry:", round(exes_matching_lex/len(lexicon), 3))
print("Number of examples with no matches at all:", len(corpus) - len(used_exes)) #this could be calculated by just testing for all Nones in sentence (if it has gone through my lemmatizer function)