Subversion Repositories SmartDukaan

Rev

Rev 8024 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
78 naveen 1
import math
2
 
71 naveen 3
def getscore(struct):
77 naveen 4
 
78 naveen 5
    score = 0.0
77 naveen 6
 
1915 rajveer 7
    type_score = 0.0
8
    screen_size_score = 0.0
9
    screen_resolution_score = 0.0
10
    number_of_colors_score = 0.0
8045 amit.gupta 11
    touch_screen_type_score = 0.0
2655 rajveer 12
 
2663 rajveer 13
    category = struct.get("category")
2655 rajveer 14
    max_screen_size = 5
15
    min_screen_size = 1.5
16
    max_resolution = 409920
17
    min_resolution = 16384
18
 
19
    if category == "Tablets":
20
        max_screen_size = 10
21
        min_screen_size = 5
22
        max_resolution = 1024000
23
        min_resolution = 200000
24
 
78 naveen 25
    if struct.has_key("features") :
26
        features = struct.get("features")
27
 
28
        # Screen Size : <=2 - 1, <=2.5 - 2, > 2.5 - 3
1915 rajveer 29
        if features.has_key("Screen size") :
30
            ss = features.get("Screen size")
78 naveen 31
 
32
            if len(ss) > 0 :
33
                ss = ss[0]
34
                ss = float(ss)
1915 rajveer 35
                print "Screen Size=" + `ss`
78 naveen 36
 
2655 rajveer 37
                if  ss >= max_screen_size :
1915 rajveer 38
                    screen_size_score = 10
78 naveen 39
 
2655 rajveer 40
                elif  ss <= min_screen_size :
1915 rajveer 41
                    screen_size_score = 0
78 naveen 42
 
1915 rajveer 43
                else :
2655 rajveer 44
                    screen_size_score = ((ss**2) - (min_screen_size**2))/((max_screen_size**2) - (min_screen_size**2))*10
78 naveen 45
 
46
        # Resolution : 320x240 px - 1, 480x360 px - 2
47
        if features.has_key("Resolution") :
48
            res = features.get("Resolution")
49
 
50
            if len(res) > 1 :
51
                width = int(res[0])
52
                height = int(res[1])
1915 rajveer 53
                area = height * width
78 naveen 54
                print "width=" + `width`
55
                print "height=" + `height`
56
 
2655 rajveer 57
                if  area < min_resolution :
1915 rajveer 58
                    screen_resolution_score = 0
78 naveen 59
 
2655 rajveer 60
                elif  area >= max_resolution :
1915 rajveer 61
                    screen_resolution_score = 10
62
 
63
                else :
2655 rajveer 64
                    screen_resolution_score = (area - min_resolution) / (max_resolution - min_resolution) * 10
1915 rajveer 65
 
78 naveen 66
        # Number of Colors : 64 K - 0.5, 256 K - 1, 16 M - 1.5, 4 B - 2
1915 rajveer 67
        if features.has_key("Number of colors") :
68
            nfcs = features.get("Number of colors")
78 naveen 69
 
70
            if len(nfcs) > 0 :
71
                nfcs = nfcs[0]
72
 
1915 rajveer 73
                if nfcs == "64 K" :
74
                    number_of_colors_score = 2
2201 rajveer 75
 
76
                if nfcs == "65 K" :
77
                    number_of_colors_score = 2
1915 rajveer 78
 
79
                elif nfcs == "256 K" :
80
                    number_of_colors_score = 6
2201 rajveer 81
 
82
                elif nfcs == "262 K" :
83
                    number_of_colors_score = 6.5
84
 
1915 rajveer 85
                elif nfcs == "16 M" :
86
                    number_of_colors_score = 9
87
 
88
                elif nfcs == "4 B" :
89
                    number_of_colors_score = 10
90
 
91
        # Type :
92
        '''
93
            Super AMOLED   10
94
            AMOLED         8
95
            OLED           6
96
            TFT LCD        6
97
            CSTN LCD       4
98
            STN LCD        2
99
        '''
78 naveen 100
 
101
        if features.has_key("Type") :
102
            type = features.get("Type")
1915 rajveer 103
            print type
78 naveen 104
            if len(type) > 0 :
105
                type = type[0]
1915 rajveer 106
                #print "Type=" + type
107
 
5244 amit.gupta 108
                if type == "HD Super AMOLED" :
109
                    type_score = 10
5245 amit.gupta 110
                elif type == "Super AMOLED Plus" :
5244 amit.gupta 111
                    type_score = 9.5
2302 rajveer 112
                elif type == "Retina Display":
5244 amit.gupta 113
                    type_score = 9
2302 rajveer 114
                elif type == "Nova Display":
5244 amit.gupta 115
                    type_score = 8.5                        
5632 amit.gupta 116
                elif type == "Ultra AMOLED" :
117
                    type_score = 8
2051 rajveer 118
                elif type == "Super AMOLED" :
5244 amit.gupta 119
                    type_score = 8
5472 amit.gupta 120
                elif type == "Super IPS LCD 2":
121
                    type_score = 8                   
2150 rajveer 122
                elif type == "Super Clear LCD":
5244 amit.gupta 123
                    type_score = 7.5
2150 rajveer 124
                elif type == "Super LCD":
5244 amit.gupta 125
                    type_score = 7.5                   
2302 rajveer 126
                elif type == "AMOLED":
5244 amit.gupta 127
                    type_score = 7.0
1915 rajveer 128
                elif type == "OLED" :
5244 amit.gupta 129
                    type_score = 5.5
1915 rajveer 130
                elif type == "TFT LCD" :
5244 amit.gupta 131
                    type_score = 5.5
1915 rajveer 132
                elif type == "CSTN LCD" :
5244 amit.gupta 133
                    type_score = 3.5
1915 rajveer 134
                elif type == "STN LCD" :
135
                    type_score = 2
6485 amit.gupta 136
                elif type == "IPS LCD" :
137
                    type_score = 7.0
6320 amit.gupta 138
                elif type == "True HD IPS Plus":
139
                    type_score = 8                   
6523 amit.gupta 140
                elif type == "Super LCD 3":
141
                    type_score = 8.5                   
2655 rajveer 142
 
143
                if category == "Tablets":
6485 amit.gupta 144
                    if type == "IPS LCD":
145
                        type_score = 9.0
2655 rajveer 146
                    if type == "TFT LCD" :
147
                        type_score = 8.5
2656 rajveer 148
                    elif type == "Super LCD":
6320 amit.gupta 149
                        type_score = 9.5
8024 amit.gupta 150
                else:
151
                    touchscreen_type_score = 8.0
8045 amit.gupta 152
 
153
        if features.has_key("Touch screen type") :
154
            touch_screen_type = features.get("Touch screen type")
155
            if len(touch_screen_type) > 0:
156
                touch_screen_type = touch_screen_type[0]
157
                if touch_screen_type == "Capacitive touchscreen":
158
                    touch_screen_type_score == 10.0
159
                elif touch_screen_type == "Resistive touchscreen":
160
                    touch_screen_type_score == 5.0
161
 
1915 rajveer 162
    print "type_score" + str(type_score)
163
    print "screen_size_score: " + str(screen_size_score)
164
    print "screen_resolution_score"  + str(screen_resolution_score)
165
    print "number_of_colors_score" + str(number_of_colors_score)
166
 
8024 amit.gupta 167
    if category == "Tablets":
168
        score = (type_score * 30.0 + screen_size_score * 50.0 + screen_resolution_score * 15.0 + number_of_colors_score * 5.0)/100
169
    else :
8045 amit.gupta 170
        score = (type_score * 30.0 + screen_size_score * 25.0 + screen_resolution_score * 20.0 + number_of_colors_score * 5.0 + 20.0)/100
8024 amit.gupta 171
 
1915 rajveer 172
    return score