Subversion Repositories SmartDukaan

Rev

Rev 77 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 77 Rev 78
Line -... Line 1...
-
 
1
import math
-
 
2
 
1
def getscore(struct):
3
def getscore(struct):
2
    
4
    
3
    score = 0
5
    score = 0.0
4
    
6
    
-
 
7
    if struct.has_key("features") :
-
 
8
        features = struct.get("features")
-
 
9
        
5
    # Screen Size : <=2 - ?, <=2.5 - ?, > 2.5 - ?
10
        # Screen Size : <=2 - 1, <=2.5 - 2, > 2.5 - 3
-
 
11
        if features.has_key("Screen Size") :
-
 
12
            ss = features.get("Screen Size")
-
 
13
            
-
 
14
            if len(ss) > 0 :
-
 
15
                ss = ss[0]
-
 
16
                ss = float(ss)
-
 
17
                print "ss=" + `ss`
6
    # Resolution
18
                
-
 
19
                if  ss <= 2 :
-
 
20
                    score += 1
-
 
21
 
-
 
22
                elif  ss <= 2.5 :
-
 
23
                    score += 2
-
 
24
 
-
 
25
                elif  ss > 2.5 :
-
 
26
                    score += 3
-
 
27
                
-
 
28
        # Resolution : 320x240 px - 1, 480x360 px - 2
-
 
29
        if features.has_key("Resolution") :
-
 
30
            res = features.get("Resolution")
-
 
31
            
-
 
32
            if len(res) > 1 :
-
 
33
                width = int(res[0])
-
 
34
                height = int(res[1])
-
 
35
                print "width=" + `width`
-
 
36
                print "height=" + `height`
7
    # Number of Colors
37
                
-
 
38
                if  width <= 320 :
-
 
39
                    score += 1
8
    
40
        
-
 
41
                elif  width > 320 :
-
 
42
                    score += 2
-
 
43
 
-
 
44
        # 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") :
-
 
46
            nfcs = features.get("Number of Colors")
-
 
47
            
-
 
48
            if len(nfcs) > 0 :
-
 
49
                nfcs = nfcs[0]
-
 
50
            
-
 
51
            if nfcs == "64 K" :
-
 
52
                score += 0.5
-
 
53
 
-
 
54
            elif nfcs == "256 K" :
-
 
55
                score += 1
-
 
56
            
-
 
57
            elif nfcs == "16 M" :
-
 
58
                score += 1.5
-
 
59
            
-
 
60
            elif nfcs == "4 B" :
-
 
61
                score += 2
-
 
62
 
-
 
63
        # REVISIT
-
 
64
        # Type : TFT - 1, Others - 0.5
-
 
65
        if features.has_key("Type") :
9
    # REVISIT - Certain type of screen are better
66
            type = features.get("Type")
10
    # Type
67
            
-
 
68
            if len(type) > 0 :
-
 
69
                type = type[0]
-
 
70
            
-
 
71
            if type == "TFT" :
-
 
72
                score += 1
-
 
73
 
-
 
74
            else :
-
 
75
                score += 0.5
11
   
76
   
12
    return score
77
    return int(math.floor(score))