-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtotal_count_chart_maker.py
More file actions
90 lines (69 loc) · 2.36 KB
/
Copy pathtotal_count_chart_maker.py
File metadata and controls
90 lines (69 loc) · 2.36 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"""
Makes the total count chart
"""
import numpy as np
import matplotlib.pyplot as plt
import sys
import matplotlib
from matplotlib.ticker import FuncFormatter
holo = []
mero = []
hyper = []
syn = []
hypo = []
same_stem = []
with open("textfiles/total_count_scatter_stem.txt") as results:
for line in results.readlines():
same_stem.append(int(line.replace("\n", "")))
with open("textfiles/total_count_scatter_holo.txt") as results:
for line in results.readlines():
holo.append(int(line.replace("\n", "")))
with open("textfiles/total_count_scatter_mero.txt") as results:
for line in results.readlines():
mero.append(int(line.replace("\n", "")))
with open("textfiles/total_count_scatter_hyper.txt") as results:
for line in results.readlines():
hyper.append(int(line.replace("\n", "")))
with open("textfiles/total_count_scatter_hypo.txt") as results:
for line in results.readlines():
hypo.append(int(line.replace("\n", "")))
with open("textfiles/total_count_scatter_syn.txt") as results:
for line in results.readlines():
syn.append(int(line.replace("\n", "")))
holo = np.array(holo)
mero = np.array(mero)
hyper = np.array(hyper)
hypo = np.array(hypo)
syn = np.array(syn)
same_stem = np.array(same_stem)
def to_percent(y, position):
# Ignore the passed in position. This has the effect of scaling the default
# tick locations.
s = str(int(round(100 * y)))
print s
# The percent symbol needs escaping in latex
if matplotlib.rcParams['text.usetex'] == True:
return s + r'$\%$'
else:
return s + '%'
#formatter = FuncFormatter(to_percent)
# Set the formatter
#plt.gca().yaxis.set_major_formatter(formatter)
# Fake data
x = np.arange(0, len(syn), 1)
area = 15 # 0 to 15 point radiuses
alpha = .4
plt.title("Count of relations by k")
plt.ylim(0, 500)
plt.xlim(0,200)
plt.scatter(x, syn, alpha=.4, label='Synonyms', color="blue")
plt.scatter(x, hyper, alpha=.4, label='Hypernyms', color="red")
plt.scatter(x, holo, alpha=.4, label='Holonyms', color="green")
plt.scatter(x, hypo, alpha=.4, label='Hyponyms', color="purple")
plt.scatter(x, mero, alpha=.4, label='Meronyms', color="orange")
plt.scatter(x, same_stem, alpha=.4, label='Same stem', color="yellow")
plt.legend()
plt.xlabel("k")
plt.ylabel("Count")
plt.tight_layout()
plt.savefig('total.png', bbox_inches='tight', pad_inches=.4)