Subversion Repositories SmartDukaan

Rev

Rev 2655 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1915 rajveer 1
def getscore(struct) :
2
 
3
    score = 0.0
4
    type_score = 0.0
5
    navigation_score = 0.0
6
    touch_screen_score = 0.0
2655 rajveer 7
 
2663 rajveer 8
    category = struct.get("category")
2655 rajveer 9
 
1915 rajveer 10
    if struct.has_key("features") :
11
        features = struct.get("features")
12
        if features.has_key("Type") :
13
            type = features.get("Type")
14
            if len(type) > 0 :
15
 
16
                if "T9 keyboard" in type:
17
                    type_score = 5.0
2547 rajveer 18
                if "Half QWERTY keyboard" in type:
1915 rajveer 19
                    type_score = 6.0
20
                if "Touchscreen T9 keyboard" in type :
21
                    type_score = 7.0
22
                if "QWERTY keyboard" in type:
23
                    type_score = 8.0
24
                if "Touchscreen QWERTY keyboard" in type:
25
                    if "QWERTY keyboard" in type:
26
                        type_score = 10.0
27
                    else:
28
                        type_score = 9.0
29
 
30
        if features.has_key("Navigation") :
2556 rajveer 31
            type = features.get("Navigation")
32
            if len(type) > 0 :
33
                if "5-way key" in type:
1915 rajveer 34
                    navigation_score = 4
2556 rajveer 35
                if "Trackball"  in type:
36
                    navigation_score = 5
37
                if "Optical joystick" in type:
38
                    navigation_score = 5
39
                if "Optical navi key" in type:
40
                    navigation_score = 5
41
                if "Trackpad" in type:
1915 rajveer 42
                    navigation_score = 6
2556 rajveer 43
                if "Optical trackpad" in type:
1915 rajveer 44
                    navigation_score = 9
2556 rajveer 45
                if "Touch navigation" in type :
1915 rajveer 46
                    navigation_score = 8
2556 rajveer 47
                    if "Trackpad" in type:
48
                        navigation_score = 9.5
49
                    if "Optical trackpad" in type:
50
                        navigation_score = 10
51
 
1915 rajveer 52
 
2556 rajveer 53
        if features.has_key("Touchscreen type") :
54
            touch_screen_type = features.get("Touchscreen type")
1915 rajveer 55
            if len(touch_screen_type) > 0 :
56
                touch_screen_type = touch_screen_type[0]
2556 rajveer 57
                if touch_screen_type == "Capacitive touchscreen" :
1915 rajveer 58
                    touch_screen_score = 9
2556 rajveer 59
                elif touch_screen_type == "Resistive touchscreen" :
1915 rajveer 60
                    touch_screen_score = 6
61
 
62
    print "type_score" + str(type_score)
63
    print "navigation_score" + str(navigation_score)
64
    print "touch_screen_score" + str(touch_screen_score)
2655 rajveer 65
 
66
    if category == "Tablets" :
67
        if touch_screen_score == 0 :
68
            score = (100*type_score)/100
69
        else :
70
            score = (60*type_score + 40*touch_screen_score)/100
1915 rajveer 71
    else :
2655 rajveer 72
        if touch_screen_score == 0 :
73
            score = (55*type_score + 45*navigation_score)/100    
74
        else :
75
            score = (40*type_score + 30*navigation_score + 30*touch_screen_score)/100
1915 rajveer 76
 
77
 
78
    return score