-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenre.py
117 lines (105 loc) · 2.37 KB
/
genre.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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import sys
def cap(num):
if (num>5):
num = 5;
elif (num<1):
num = 1;
return num;
def convert(genre):
reflective = intense = upbeat = energetic = 1;
if genre == "blues":
reflective += .85;
intense += .01;
upbeat += -.09;
energetic += .12;
elif genre == "jazz":
reflective += .83;
intense += .04;
upbeat += .07;
energetic += .15;
elif genre == "classical":
reflective += .66;
intense += .14;
upbeat += .02;
energetic += -.13;
elif genre == "folk":
reflective += .64;
intense += .09;
upbeat += .15;
energetic += -.16;
elif genre == "rock":
reflective += .17;
intense += .85;
upbeat += -.04;
energetic += -.07;
elif genre == "alternative":
reflective += .02;
intense += .8;
upbeat += .13;
energetic += .04;
elif genre == "retro metal":
reflective += .07;
intense += .75;
upbeat += -.11;
energetic += .04;
elif genre == "country":
reflective += -.06;
intense += .05;
upbeat += .72;
energetic += -.03;
elif genre == "pop":
reflective += -.2;
intense += .06;
upbeat += .59;
energetic += .45;
elif genre == "rap":
reflective += -.19;
intense += -.12;
upbeat += .17;
energetic += .79;
elif genre == "soul":
reflective += .39;
intense += -.11;
upbeat += .11;
energetic += .69;
elif genre == "electronic":
reflective += -.02;
intense += .15;
upbeat += -.01;
energetic += .6;
scale1 = 10;
reflective *= scale1;
intense *= scale1;
upbeat *= scale1;
energetic *= scale1;
extra = (reflective*.013 + intense*(-.083) + upbeat*.057 + energetic*.163)/.316;
agree = (reflective*(-.015) + intense*(-.063) + upbeat*.119 + energetic*.095)/.392;
conc = (reflective*(-.044) + intense*(-.094) + upbeat*.217 + energetic*.013)/.368;
emot = (reflective*.027 + intense*(-.053) + upbeat*(-.051) + energetic*.072)/.202;
open = (reflective*.361 + intense*.226 + upbeat*(-.128) + energetic*.093)/.808;
scale = .60;
extra *= scale;
agree *= scale;
conc *= scale;
emot *= scale;
open *= scale;
shift = 1;
extra += shift;
agree += shift;
conc += shift;
emot += shift;
open += shift;
emot = 5 - emot;#convert from emotional stability to neuroticism
extra = cap(extra);
agree = cap(agree);
conc = cap(conc);
emot = cap(emot);
open = cap(open);
person = [extra, agree, conc, emot, open];
return person;
#def main():
# genre = sys.argv[1]
# person = convert(genre);
# print person
# return
#main()