Rev 2664 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
import mathdef getscore(struct):score = 0.0battery_type_score = 0.0twog_talktime_score = 0.0threeg_talktime_score = 0.0twog_standbytime_score = 0.0threeg_standbytime_score = 0.0usage_time_score = 0.0category = struct.get("category")min_battery_capacity = 800max_battery_capacity = 3000if category == "Tablets":min_battery_capacity = 1000max_battery_capacity = 5000if struct.has_key("features") :features = struct.get("features")battery_capacity = 0.0last = "0"battery_type = features.get("Battery type")battery_type = battery_type[0]battery_type = battery_type.split(" ")print battery_typefor part in battery_type:if part.find("mAh") > -1:try:battery_capacity = float(last)except:battery_capacity = 1600print `last`last = partprint "battery_capacity" + `battery_capacity`if battery_capacity < min_battery_capacity :battery_type_score = 3elif battery_capacity > max_battery_capacity :battery_type_score = 10else :battery_type_score = (battery_capacity - min_battery_capacity)/(max_battery_capacity-min_battery_capacity)*7.0battery_type_score = battery_type_score + 3.0score = (100*battery_type_score)/100.0return score