-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_device.py
50 lines (40 loc) · 1.84 KB
/
run_device.py
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
import utils
import probe
import pickle
import sys
if __name__ == '__main__':
sample_size = 100000
categories = ["Booking-pc", "Booking-mobile"]
start_years = [2018, 2018]
end_years = [2018, 2018]
line_styles = ['-', '--', '-.']
colors = ["blue", "orange", "green"]
titles = ["Word level sentiment", "Enhanced sentiment", "Absolute sentiment intensity", "#words",
"% of dichotomous reviews", "% of frequent sentiment words use"]
display_titles = ["Sentiment", "Enhanced", "Absolute", "#words", "one-sided", "freq"]
functions = [probe.calc_sen, probe.calc_sen_full, probe.calc_abs, probe.calc_len, probe.calc_one_sided,
probe.calc_top_coverage]
add_lexicon = [True, False, True, False, False, True]
force_positive = [False, False, False, True, True, True]
sen = [10, 10]
lexicon = utils.load_lexicon("data/vader_lexicon.txt")
max_proc = None
if len(sys.argv) > 1:
max_proc = int(sys.argv[1])
else:
max_proc = None
for t in range(len(functions)):
print(titles[t])
dicts = []
std_dicts = []
for i in range(2):
if add_lexicon[t]:
calc_args = (categories[i], sample_size, lexicon)
else:
calc_args = (categories[i], sample_size)
task_dict, std_dict = probe.parallel_calculation_per_year(calc_args, functions[t], start_years[i],
end_years[i],
sen[i], desc=titles[t], max_processes = max_proc)
dicts.append(task_dict)
std_dicts.append(std_dict)
print("The {} for {} is {}".format(titles[t], categories[i], round(task_dict[start_years[i]],3)))