Subversion Repositories SmartDukaan

Rev

Rev 323 | Rev 1927 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 323 Rev 1915
Line 2... Line 2...
2
 
2
 
3
def getscore(struct):
3
def getscore(struct):
4
    
4
    
5
    score = 0.0
5
    score = 0.0
6
    
6
    
-
 
7
    type_score = 0.0
-
 
8
    screen_size_score = 0.0
-
 
9
    screen_resolution_score = 0.0
-
 
10
    number_of_colors_score = 0.0
-
 
11
 
7
    if struct.has_key("features") :
12
    if struct.has_key("features") :
8
        features = struct.get("features")
13
        features = struct.get("features")
9
        
14
        
10
        # Screen Size : <=2 - 1, <=2.5 - 2, > 2.5 - 3
15
        # Screen Size : <=2 - 1, <=2.5 - 2, > 2.5 - 3
11
        if features.has_key("Screen Size") :
16
        if features.has_key("Screen size") :
12
            ss = features.get("Screen Size")
17
            ss = features.get("Screen size")
13
            
18
            
14
            if len(ss) > 0 :
19
            if len(ss) > 0 :
15
                ss = ss[0]
20
                ss = ss[0]
16
                ss = float(ss)
21
                ss = float(ss)
17
                print "ss=" + `ss`
22
                print "Screen Size=" + `ss`
18
                
23
                
19
                if  ss <= 2 :
24
                if  ss >= 5 :
20
                    score += 1
25
                    screen_size_score = 10
21
 
26
 
22
                elif  ss <= 2.5 :
27
                elif  ss <= 1.5 :
23
                    score += 2
28
                    screen_size_score = 0
24
 
29
 
25
                elif  ss > 2.5 :
30
                else :
26
                    score += 3
31
                    screen_size_score = ((ss**2) - (1.5**2))/((5**2) - (1.5**2))*10
27
                
32
                
28
        # Resolution : 320x240 px - 1, 480x360 px - 2
33
        # Resolution : 320x240 px - 1, 480x360 px - 2
29
        if features.has_key("Resolution") :
34
        if features.has_key("Resolution") :
30
            res = features.get("Resolution")
35
            res = features.get("Resolution")
31
            
36
            
32
            if len(res) > 1 :
37
            if len(res) > 1 :
33
                width = int(res[0])
38
                width = int(res[0])
34
                height = int(res[1])
39
                height = int(res[1])
-
 
40
                area = height * width
35
                print "width=" + `width`
41
                print "width=" + `width`
36
                print "height=" + `height`
42
                print "height=" + `height`
37
                
43
                
38
                if  width <= 320 :
44
                if  area < 16384 :
39
                    score += 1
45
                    screen_resolution_score = 0
40
        
46
        
41
                elif  width > 320 :
47
                elif  area >= 409920 :
-
 
48
                    screen_resolution_score = 10
42
                    score += 2
49
                    
43
 
-
 
-
 
50
                else :
-
 
51
                    screen_resolution_score = (area - 16384) / (409920 - 16384) * 10
-
 
52
                    
44
        # Number of Colors : 64 K - 0.5, 256 K - 1, 16 M - 1.5, 4 B - 2
53
        # Number of Colors : 64 K - 0.5, 256 K - 1, 16 M - 1.5, 4 B - 2
45
        if features.has_key("Number of Colors") :
54
        if features.has_key("Number of colors") :
46
            nfcs = features.get("Number of Colors")
55
            nfcs = features.get("Number of colors")
47
            
56
            
48
            if len(nfcs) > 0 :
57
            if len(nfcs) > 0 :
49
                nfcs = nfcs[0]
58
                nfcs = nfcs[0]
50
            
59
            
51
            if nfcs == "64 K" :
60
                if nfcs == "64 K" :
52
                score += 0.5
61
                    number_of_colors_score = 2
53
 
62
    
54
            elif nfcs == "256 K" :
63
                elif nfcs == "256 K" :
55
                score += 1
64
                    number_of_colors_score = 6
56
            
65
                
57
            elif nfcs == "16 M" :
66
                elif nfcs == "16 M" :
58
                score += 1.5
67
                    number_of_colors_score = 9
59
            
68
                
60
            elif nfcs == "4 B" :
69
                elif nfcs == "4 B" :
-
 
70
                    number_of_colors_score = 10
-
 
71
        
-
 
72
        # Type :
-
 
73
        '''
-
 
74
            Super AMOLED   10
-
 
75
            AMOLED         8
-
 
76
            OLED           6
-
 
77
            TFT LCD        6
-
 
78
            CSTN LCD       4
61
                score += 2
79
            STN LCD        2
-
 
80
        '''
62
 
81
 
63
        # REVISIT
-
 
64
        # Type : TFT - 1, Others - 0.5
-
 
65
        if features.has_key("Type") :
82
        if features.has_key("Type") :
66
            type = features.get("Type")
83
            type = features.get("Type")
67
            
84
            print type
68
            if len(type) > 0 :
85
            if len(type) > 0 :
69
                type = type[0]
86
                type = type[0]
-
 
87
                #print "Type=" + type
70
            
88
                        
-
 
89
                if type == "Super AMOLED" :
-
 
90
                    type_score = 10
-
 
91
                elif type == "AMOLED" :
-
 
92
                    type_score = 8
-
 
93
                elif type == "OLED" :
-
 
94
                    type_score = 6
71
            if type == "TFT" :
95
                elif type == "TFT LCD" :
72
                score += 1
96
                    type_score = 6
73
 
-
 
-
 
97
                elif type == "CSTN LCD" :
74
            else :
98
                    type_score = 4
-
 
99
                elif type == "STN LCD" :
75
                score += 0.5
100
                    type_score = 2
76
   
101
   
-
 
102
 
-
 
103
    print "type_score" + str(type_score)
-
 
104
    print "screen_size_score: " + str(screen_size_score)
-
 
105
    print "screen_resolution_score"  + str(screen_resolution_score)
-
 
106
    print "number_of_colors_score" + str(number_of_colors_score)
-
 
107
    
-
 
108
    
-
 
109
    score = (type_score * 30 + screen_size_score * 50 + screen_resolution_score * 15 + number_of_colors_score * 5)/100
77
    return int(math.floor(score))
110
    return score