Subversion Repositories SmartDukaan

Rev

Rev 2664 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2664 Rev 7752
Line 11... Line 11...
11
    usage_time_score = 0.0
11
    usage_time_score = 0.0
12
 
12
 
13
    category = struct.get("category")    
13
    category = struct.get("category")    
14
    
14
    
15
    min_battery_capacity = 800
15
    min_battery_capacity = 800
16
    max_battery_capacity = 1800
16
    max_battery_capacity = 3000
17
    
17
    
18
    if category == "Tablets":
18
    if category == "Tablets":
19
        min_battery_capacity = 1000
19
        min_battery_capacity = 1000
20
        max_battery_capacity = 5000
20
        max_battery_capacity = 5000
21
        
21
        
Line 32... Line 32...
32
        for part in battery_type:
32
        for part in battery_type:
33
            if part.find("mAh") > -1:
33
            if part.find("mAh") > -1:
34
                try:
34
                try:
35
                    battery_capacity = float(last)
35
                    battery_capacity = float(last)
36
                except:
36
                except:
37
                    battery_capacity = 1200
37
                    battery_capacity = 1600
38
            print `last`
38
            print `last`
39
            last = part
39
            last = part
40
            
40
            
41
        print "battery_capacity" + `battery_capacity`
41
        print "battery_capacity" + `battery_capacity`
42
        if battery_capacity < min_battery_capacity :
42
        if battery_capacity < min_battery_capacity :
Line 45... Line 45...
45
            battery_type_score = 10
45
            battery_type_score = 10
46
        else :
46
        else :
47
            battery_type_score = (battery_capacity - min_battery_capacity)/(max_battery_capacity-min_battery_capacity)*7.0
47
            battery_type_score = (battery_capacity - min_battery_capacity)/(max_battery_capacity-min_battery_capacity)*7.0
48
            battery_type_score = battery_type_score + 3.0
48
            battery_type_score = battery_type_score + 3.0
49
            
49
            
50
        if features.has_key("Usage time") :
-
 
51
            usage_time = features.get("Usage time")
-
 
52
            usage_time = usage_time[0]
-
 
53
            usage_time = usage_time.split(" ")
-
 
54
            usage_time = float(usage_time[0])
-
 
55
            if usage_time > 10 :
-
 
56
                usage_time_score = 10
-
 
57
            else:
-
 
58
                usage_time_score = usage_time
-
 
59
                 
-
 
60
    if struct.has_key("childrenslides") :
-
 
61
        childrenslides = struct.get("childrenslides")
-
 
62
        
-
 
63
        if childrenslides.has_key("Capacity") :
-
 
64
            capacity = childrenslides.get("Capacity")
-
 
65
            if capacity.has_key("features") :
-
 
66
                features = capacity.get("features")
-
 
67
                          
-
 
68
            if capacity.has_key("childrenslides") :
-
 
69
                childrenslides = capacity.get("childrenslides")
-
 
70
                
-
 
71
                if childrenslides.has_key("Talk time") :
-
 
72
                    talktime = childrenslides.get("Talk time")
-
 
73
                    
-
 
74
                    if talktime.has_key("features") :
-
 
75
                        features = talktime.get("features")
-
 
76
                        
-
 
77
                        # Capacity > Talk time > 2G : <5 - 0.5, <10 - 1, >10 - 1.5
-
 
78
                        if features.has_key("2G") :
-
 
79
                            twog = features.get("2G")
-
 
80
                            if len(twog) > 0 :
-
 
81
                                twog = twog[0]
-
 
82
                                twog = twog.split(" ")
-
 
83
                                twog = float(twog[0])
-
 
84
 
-
 
85
                                print "twog=" + `twog`
-
 
86
                                
-
 
87
                                if twog < 3 :
-
 
88
                                    twog_talktime_score = 3.0
-
 
89
                                
-
 
90
                                elif twog >= 15 :
-
 
91
                                    twog_talktime_score = 10.0
-
 
92
    
-
 
93
                                else :
-
 
94
                                    twog_talktime_score = 3 + (twog - 3) / (15 - 3) * 7 
-
 
95
                                
-
 
96
                        # Capacity > Talk time > 3G : <5 - 0.5, <10 - 1, >10 - 1.5
-
 
97
                        if features.has_key("3G") :
-
 
98
                            threeg = features.get("3G")
-
 
99
                            
-
 
100
                            if len(threeg) > 0 :
-
 
101
                                threeg = threeg[0]
-
 
102
                                threeg = threeg.split(" ")
-
 
103
                                threeg = float(threeg[0])
-
 
104
                                print "threeg=" + `threeg`
-
 
105
    
-
 
106
                                if threeg < 2 :
-
 
107
                                    threeg_talktime_score = 3.0
-
 
108
                                
-
 
109
                                elif threeg >= 8 :
-
 
110
                                    threeg_talktime_score = 10.0
-
 
111
    
-
 
112
                                else :
-
 
113
                                    threeg_talktime_score = 3.0 + (threeg - 3) / (8 - 2) * 7.0
-
 
114
                                                            
-
 
115
                if childrenslides.has_key("Standby time") :
-
 
116
                    standbytime = childrenslides.get("Standby time")
-
 
117
                    
-
 
118
                    if standbytime.has_key("features") :
-
 
119
                        features = standbytime.get("features")
-
 
120
                        
-
 
121
                        # Capacity > Standby time > 2G : <10 - 0.5, <20 - 1, >20 - 1.5
-
 
122
                        if features.has_key("2G") :
-
 
123
                            twog = features.get("2G")
-
 
124
 
50
 
125
                            if len(twog) > 0 :
-
 
126
                                twog = twog[0]
-
 
127
                                twog = twog.split(" ")
-
 
128
                                twog = float(twog[0])
-
 
129
 
51
 
130
                                print "twog=" + `twog`
-
 
131
                                
-
 
132
                                if twog < 5 :
-
 
133
                                    twog_standbytime_score = 2.0
-
 
134
                                
-
 
135
                                elif twog >= 30 :
-
 
136
                                    twog_standbytime_score = 10.0
-
 
137
    
-
 
138
                                else :
-
 
139
                                    twog_standbytime_score = 2 + (twog - 5) / (30 - 5) * 8 
-
 
140
                                    
-
 
141
                        # Capacity > Standby time > 3G : <10 - 0.5, <20 - 1, >20 - 1.5
-
 
142
                        if features.has_key("3G") :
-
 
143
                            threeg = features.get("3G")
-
 
144
                            
-
 
145
                            if len(threeg) > 0 :
-
 
146
                                threeg = threeg[0]
-
 
147
                                threeg = threeg.split(" ")
-
 
148
                                threeg = float(threeg[0])
-
 
149
                                print "threeg=" + `threeg`
-
 
150
    
-
 
151
                                if threeg < 5 :
-
 
152
                                    threeg_standbytime_score = 2.0 
-
 
153
                                
-
 
154
                                elif threeg >= 30 :
-
 
155
                                    threeg_standbytime_score = 10.0
-
 
156
    
-
 
157
                                else :
-
 
158
                                    threeg_standbytime_score = 2 +  (threeg - 5) / (30 - 5) * 8
-
 
159
 
-
 
160
    print "battery_type_score" + `battery_type_score`
-
 
161
    print "twog_talktime_score" + `twog_talktime_score`
-
 
162
    print "threeg_talktime_score" + `threeg_talktime_score`
-
 
163
    print "twog_standbytime_score" + `twog_standbytime_score`
-
 
164
    print "threeg_standbytime_score" + `threeg_standbytime_score`
-
 
165
 
-
 
166
    if category == "Tablets":
-
 
167
        score = (100*battery_type_score)/100.0
52
    score = (100*battery_type_score)/100.0
168
    elif usage_time_score != 0:
-
 
169
        score = (40*battery_type_score + 60*usage_time_score)/100
-
 
170
    elif threeg_talktime_score == 0:
-
 
171
        score = (40*battery_type_score + 30*twog_talktime_score + 30*twog_standbytime_score )/100
-
 
172
    else :
-
 
173
        score = (40*battery_type_score + 20*twog_talktime_score + 10*threeg_talktime_score + 20*twog_standbytime_score + 10*threeg_standbytime_score)/100
-
 
174
    return score
53
    return score