| 4036 |
varun.gupt |
1 |
import utils
|
|
|
2 |
|
|
|
3 |
def getscore(struct):
|
|
|
4 |
|
|
|
5 |
score = 0.0
|
|
|
6 |
ram_score = 0.0
|
|
|
7 |
expansion_capacity_score = 0.0
|
|
|
8 |
ram_type_score = 0.0
|
|
|
9 |
clock_speed_score = 0.0
|
|
|
10 |
|
|
|
11 |
if struct.has_key('features'):
|
|
|
12 |
features = struct.get('features')
|
|
|
13 |
|
|
|
14 |
if features.has_key("RAM"):
|
|
|
15 |
ram = float(features.get('RAM')[0]) / (1024.0 * 1024.0) #converting to GBs
|
|
|
16 |
|
|
|
17 |
if ram <= 2.0:
|
|
|
18 |
ram_score = 4
|
|
|
19 |
elif ram > 2.0 and ram < 4.0:
|
|
|
20 |
ram_score = 4 + (ram - 2.0) * 6.0 / 2
|
|
|
21 |
else:
|
|
|
22 |
ram_score = 10
|
|
|
23 |
|
|
|
24 |
if features.has_key('Expansion capacity'):
|
|
|
25 |
expansion_capacity = features.get('Expansion capacity')
|
|
|
26 |
|
|
|
27 |
if expansion_capacity == 0:
|
|
|
28 |
expansion_capacity_score = 0
|
|
|
29 |
elif expansion_capacity == 2:
|
|
|
30 |
expansion_capacity_score = 2.5
|
|
|
31 |
elif expansion_capacity == 4:
|
|
|
32 |
expansion_capacity_score = 5
|
|
|
33 |
elif expansion_capacity == 8:
|
|
|
34 |
expansion_capacity_score = 7.5
|
|
|
35 |
elif expansion_capacity ==16:
|
|
|
36 |
expansion_capacity_score = 10
|
|
|
37 |
|
|
|
38 |
if features.has_key('RAM type'):
|
|
|
39 |
ram_type = features.get('RAM type')
|
|
|
40 |
ram_type_score = 10 if ram_type == 'DDR3' else 5
|
|
|
41 |
|
|
|
42 |
if features.has_key('Memory clock speed'):
|
|
|
43 |
pass #TODO
|
|
|
44 |
|
|
|
45 |
score = (70 * ram_score + 15 * expansion_capacity_score + 15 * ram_type_score) / 100
|
|
|
46 |
return score
|
|
|
47 |
|
|
|
48 |
print "expSlide=" + `expSlide`
|
|
|
49 |
|
|
|
50 |
struct = utils.contentModel2Struct(expSlide, categoryObj)
|
|
|
51 |
print "struct=" + `struct`
|
|
|
52 |
|
|
|
53 |
score = getscore(struct)
|