Subversion Repositories SmartDukaan

Rev

Rev 323 | Rev 2547 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

def getscore(struct) :
    
    score = 0.0
    type_score = 0.0
    navigation_score = 0.0
    touch_screen_score = 0.0
    
    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.0
                if "Half QWERTY keyboard" :
                    type_score = 6.0
                if "Touchscreen T9 keyboard" in type :
                    type_score = 7.0
                if "QWERTY keyboard" in type:
                    type_score = 8.0
                if "Touchscreen QWERTY keyboard" in type:
                    if "QWERTY keyboard" in type:
                        type_score = 10.0
                    else:
                        type_score = 9.0
        
        if features.has_key("Navigation") :
            navigation = features.get("Navigation")
            if len(navigation) > 0 :
                type = navigation[0]
                if type == "5-way key" :
                    navigation_score = 4
                elif type == "Trackpad" :
                    navigation_score = 6
                elif type == "Optical Trackpad" :
                    navigation_score = 9
                if type == "Touch Navigation" :
                    navigation_score = 8
                if type == "Trackball" :
                    navigation_score = 5
                if type == "Optical Joystick" :
                    navigation_score = 5
                if type == "Optical Navikey" :
                    navigation_score = 5
                    
        if 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" :
                    touch_screen_score = 9
                elif touch_screen_type == "Resistive" :
                    touch_screen_score = 6
    
    print "type_score" + str(type_score)
    print "navigation_score" + str(navigation_score)
    print "touch_screen_score" + str(touch_screen_score)
                     
    if touch_screen_score == 0 :
        score = (55*type_score + 45*navigation_score)/100    
    else :
        score = (40*type_score + 30*navigation_score + 30*touch_screen_score)/100
    
    
    
    return score