Rev 2658 | Rev 3314 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
def getscore(struct):score = 0.0weight_score = 0.0thickness_score = 0.0category = struct.get("category")max_weight = 250min_weight = 60max_thickness = 20min_thickness = 9if category == "Tablets":max_weight = 740min_weight = 400max_thickness = 13min_thickness = 10if struct.has_key("features") :features = struct.get("features")# Weight : >250-10, <=60-10, others linearif features.has_key("Weight") :weight = features.get("Weight")if len(weight) > 0 :weight = float(weight[0])print "weight=" + `weight`if weight > max_weight :weight_score = 0elif weight <= min_weight :weight_score = 10else :weight_score = 10 - (weight - min_weight) / (max_weight - min_weight) * 10# Size : Thickness <=10-4, <=12-3, <=14-2, >14-1if features.has_key("Size") :size = features.get("Size")if len(size) > 2 :thickness = float(size[2])print "thickness=" + `thickness`if thickness <= min_thickness :thickness_score = 10elif thickness > max_thickness :thickness_score = 0else :thickness_score = 10 - (thickness - min_thickness) / (max_thickness - min_thickness) * 10score = (weight_score*50 + thickness_score*50)/100.0return score