Subversion Repositories SmartDukaan

Rev

Rev 2664 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
75 naveen 1
import math
2
 
71 naveen 3
def getscore(struct):
75 naveen 4
 
5
    score = 0.0
1915 rajveer 6
    battery_type_score = 0.0
7
    twog_talktime_score = 0.0
8
    threeg_talktime_score = 0.0
9
    twog_standbytime_score = 0.0
10
    threeg_standbytime_score = 0.0
2454 rajveer 11
    usage_time_score = 0.0
2655 rajveer 12
 
13
    category = struct.get("category")    
75 naveen 14
 
2655 rajveer 15
    min_battery_capacity = 800
7752 amit.gupta 16
    max_battery_capacity = 3000
2655 rajveer 17
 
18
    if category == "Tablets":
19
        min_battery_capacity = 1000
20
        max_battery_capacity = 5000
21
 
75 naveen 22
    if struct.has_key("features") :
1915 rajveer 23
        features = struct.get("features")
2556 rajveer 24
 
1915 rajveer 25
        battery_capacity = 0.0
26
        last = "0"
27
        battery_type = features.get("Battery type")
28
        battery_type = battery_type[0]
29
        battery_type = battery_type.split(" ")
2454 rajveer 30
 
1915 rajveer 31
        print battery_type
32
        for part in battery_type:
33
            if part.find("mAh") > -1:
34
                try:
35
                    battery_capacity = float(last)
36
                except:
7752 amit.gupta 37
                    battery_capacity = 1600
1915 rajveer 38
            print `last`
39
            last = part
40
 
41
        print "battery_capacity" + `battery_capacity`
2655 rajveer 42
        if battery_capacity < min_battery_capacity :
1915 rajveer 43
            battery_type_score = 3
2655 rajveer 44
        elif battery_capacity > max_battery_capacity :
1915 rajveer 45
            battery_type_score = 10
46
        else :
2655 rajveer 47
            battery_type_score = (battery_capacity - min_battery_capacity)/(max_battery_capacity-min_battery_capacity)*7.0
1915 rajveer 48
            battery_type_score = battery_type_score + 3.0
49
 
50
 
51
 
7752 amit.gupta 52
    score = (100*battery_type_score)/100.0
2657 rajveer 53
    return score