Rev 2556 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
def getscore(struct) :score = 0.0type_score = 0.0navigation_score = 0.0touch_screen_score = 0.0category = struct.has_key("category")if struct.has_key("features") :features = struct.get("features")if features.has_key("Type") :type = features.get("Type")if len(type) > 0 :if "T9 keyboard" in type:type_score = 5.0if "Half QWERTY keyboard" in type:type_score = 6.0if "Touchscreen T9 keyboard" in type :type_score = 7.0if "QWERTY keyboard" in type:type_score = 8.0if "Touchscreen QWERTY keyboard" in type:if "QWERTY keyboard" in type:type_score = 10.0else:type_score = 9.0if features.has_key("Navigation") :type = features.get("Navigation")if len(type) > 0 :if "5-way key" in type:navigation_score = 4if "Trackball" in type:navigation_score = 5if "Optical joystick" in type:navigation_score = 5if "Optical navi key" in type:navigation_score = 5if "Trackpad" in type:navigation_score = 6if "Optical trackpad" in type:navigation_score = 9if "Touch navigation" in type :navigation_score = 8if "Trackpad" in type:navigation_score = 9.5if "Optical trackpad" in type:navigation_score = 10if features.has_key("Touchscreen type") :touch_screen_type = features.get("Touchscreen type")if len(touch_screen_type) > 0 :touch_screen_type = touch_screen_type[0]if touch_screen_type == "Capacitive touchscreen" :touch_screen_score = 9elif touch_screen_type == "Resistive touchscreen" :touch_screen_score = 6print "type_score" + str(type_score)print "navigation_score" + str(navigation_score)print "touch_screen_score" + str(touch_screen_score)if category == "Tablets" :if touch_screen_score == 0 :score = (100*type_score)/100else :score = (60*type_score + 40*touch_screen_score)/100else :if touch_screen_score == 0 :score = (55*type_score + 45*navigation_score)/100else :score = (40*type_score + 30*navigation_score + 30*touch_screen_score)/100return score