Rev 6485 | Rev 7974 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
import mathdef getscore(struct):score = 0.0type_score = 0.0screen_size_score = 0.0screen_resolution_score = 0.0number_of_colors_score = 0.0category = struct.get("category")max_screen_size = 5min_screen_size = 1.5max_resolution = 409920min_resolution = 16384if category == "Tablets":max_screen_size = 10min_screen_size = 5max_resolution = 1024000min_resolution = 200000if struct.has_key("features") :features = struct.get("features")# Screen Size : <=2 - 1, <=2.5 - 2, > 2.5 - 3if features.has_key("Screen size") :ss = features.get("Screen size")if len(ss) > 0 :ss = ss[0]ss = float(ss)print "Screen Size=" + `ss`if ss >= max_screen_size :screen_size_score = 10elif ss <= min_screen_size :screen_size_score = 0else :screen_size_score = ((ss**2) - (min_screen_size**2))/((max_screen_size**2) - (min_screen_size**2))*10# Resolution : 320x240 px - 1, 480x360 px - 2if features.has_key("Resolution") :res = features.get("Resolution")if len(res) > 1 :width = int(res[0])height = int(res[1])area = height * widthprint "width=" + `width`print "height=" + `height`if area < min_resolution :screen_resolution_score = 0elif area >= max_resolution :screen_resolution_score = 10else :screen_resolution_score = (area - min_resolution) / (max_resolution - min_resolution) * 10# Number of Colors : 64 K - 0.5, 256 K - 1, 16 M - 1.5, 4 B - 2if features.has_key("Number of colors") :nfcs = features.get("Number of colors")if len(nfcs) > 0 :nfcs = nfcs[0]if nfcs == "64 K" :number_of_colors_score = 2if nfcs == "65 K" :number_of_colors_score = 2elif nfcs == "256 K" :number_of_colors_score = 6elif nfcs == "262 K" :number_of_colors_score = 6.5elif nfcs == "16 M" :number_of_colors_score = 9elif nfcs == "4 B" :number_of_colors_score = 10# Type :'''Super AMOLED 10AMOLED 8OLED 6TFT LCD 6CSTN LCD 4STN LCD 2'''if features.has_key("Type") :type = features.get("Type")print typeif len(type) > 0 :type = type[0]#print "Type=" + typeif type == "HD Super AMOLED" :type_score = 10elif type == "Super AMOLED Plus" :type_score = 9.5elif type == "Retina Display":type_score = 9elif type == "Nova Display":type_score = 8.5elif type == "Ultra AMOLED" :type_score = 8elif type == "Super AMOLED" :type_score = 8elif type == "Super IPS LCD 2":type_score = 8elif type == "Super Clear LCD":type_score = 7.5elif type == "Super LCD":type_score = 7.5elif type == "AMOLED":type_score = 7.0elif type == "OLED" :type_score = 5.5elif type == "TFT LCD" :type_score = 5.5elif type == "CSTN LCD" :type_score = 3.5elif type == "STN LCD" :type_score = 2elif type == "IPS LCD" :type_score = 7.0elif type == "True HD IPS Plus":type_score = 8elif type == "Super LCD 3":type_score = 8.5if category == "Tablets":if type == "IPS LCD":type_score = 9.0if type == "TFT LCD" :type_score = 8.5elif type == "Super LCD":type_score = 9.5print "type_score" + str(type_score)print "screen_size_score: " + str(screen_size_score)print "screen_resolution_score" + str(screen_resolution_score)print "number_of_colors_score" + str(number_of_colors_score)score = (type_score * 30.0 + screen_size_score * 50.0 + screen_resolution_score * 15.0 + number_of_colors_score * 5.0)/100return score