Subversion Repositories SmartDukaan

Rev

Rev 2655 | 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

    category = struct.get("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.0
                if "Half QWERTY keyboard" in type:
                    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") :
            type = features.get("Navigation")
            if len(type) > 0 :
                if "5-way key" in type:
                    navigation_score = 4
                if "Trackball"  in type:
                    navigation_score = 5
                if "Optical joystick" in type:
                    navigation_score = 5
                if "Optical navi key" in type:
                    navigation_score = 5
                if "Trackpad" in type:
                    navigation_score = 6
                if "Optical trackpad" in type:
                    navigation_score = 9
                if "Touch navigation" in type :
                    navigation_score = 8
                    if "Trackpad" in type:
                        navigation_score = 9.5
                    if "Optical trackpad" in type:
                        navigation_score = 10

                    
        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 touchscreen" :
                    touch_screen_score = 9
                elif touch_screen_type == "Resistive touchscreen" :
                    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 category == "Tablets" :
        if touch_screen_score == 0 :
            score = (100*type_score)/100
        else :
            score = (60*type_score + 40*touch_screen_score)/100
    else :
        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