Subversion Repositories SmartDukaan

Rev

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

Rev 323 Rev 1915
Line 1... Line 1...
1
import math
1
import math
2
 
2
 
3
def getscore(struct) :
3
def getscore(struct) :
4
    score = 0.0
4
    score = 0.0
-
 
5
    resolution_score = 0.0
-
 
6
    flash_score = 0.0
-
 
7
    image_formats_score = 0.0
-
 
8
    secondary_camera_score = 0.0
-
 
9
    additional_camera_features_score = 0.0
5
 
10
 
6
    if struct.has_key("features") :
11
    if struct.has_key("features") :
7
        features = struct.get("features")
12
        features = struct.get("features")
8
        
13
        
9
        if features.has_key("Resolution") :
14
        if features.has_key("Resolution") :
10
            resolution = features.get("Resolution") 
15
            resolution = features.get("Resolution") 
11
            if len(resolution) > 0 :
16
            if len(resolution) > 0 :
12
                resolution = float(resolution[0])
17
                resolution = float(resolution[0])
13
                print "resolution=" + `resolution`
18
                print "resolution=" + `resolution`
14
                
19
                
15
                # Resolution : <=2 - 1, <=3 - 2, >3 - 3
-
 
16
                if resolution <= 2 :
20
                if resolution <= 1.3 :
17
                    score = score + 1
21
                    resolution_score = 2.0
18
                    
22
                    
19
                elif resolution <= 3 :
23
                elif resolution >= 8 :
20
                    score = score + 2
24
                    resolution_score = 10.0
21
                    
25
                    
22
                elif resolution > 3 :
26
                else :
23
                    score = score + 3
27
                    resolution_score = 2.0 + (resolution - 1.3) / (8 - 1.3) * (10 - 2)
24
 
28
 
25
        if features.has_key("Flash") :
29
        if features.has_key("Flash") :
26
            flash = features.get("Flash")
30
            flash = features.get("Flash")
27
            if len(flash) > 0 :
31
            if len(flash) > 0 :
28
                flash = flash[0]
32
                flash = flash[0]
29
                print "flash=" + `flash`
33
                print "flash=" + `flash`
30
                
34
                
31
                # Flash : LED - 0.5, Dual-LED - 1.0
35
                
32
                if flash == "LED" :
36
                if flash == "LED" :
33
                    print "Value is LED"
37
                    print "Value is LED"
-
 
38
                    flash_score = 6.0
-
 
39
                    
-
 
40
                elif flash == "Xenon" :
34
                    score = score + 0.5
41
                    flash_score = 8.0
35
                    
42
                    
36
                elif flash == "Dual-LED" :
43
                elif flash == "Dual-LED" :
37
                    score = score + 1
44
                    flash_score = 9.0 
38
    
45
    
39
        if features.has_key("Still Image Formats") :
46
        if features.has_key("Image formats") :
40
            siformats = features.get("Still Image Formats")
47
            image_formats = features.get("Image formats")
41
            print "siformats=" + `siformats`
48
            print "image_formats=" + `image_formats`
42
            
49
            
43
            # Still Image Formats : count <=2 - 0.5, >2 - 1
50
            # Still Image Formats : count <=2 - 0.5, >2 - 1
44
            if len(siformats) <= 2 :
51
            if len(image_formats) == 1 :
-
 
52
                image_formats_score = 6.0
-
 
53
            
-
 
54
            elif len(image_formats) == 2 :
45
                score = score + 0.5
55
                image_formats_score = 8.0
46
            
56
            
47
            elif len(siformats) > 2 :
57
            elif len(image_formats) >= 3 :
48
                score = score + 1
58
                image_formats_score = 10.0
49
            
59
            
50
        if features.has_key("Additional Camera features") :
60
        if features.has_key("Additional camera features") :
-
 
61
            additional_camera_features = features.get("Additional camera features")
51
            # Additional Camera features : 1, 0
62
            if len(additional_camera_features) > 10 :
-
 
63
                additional_camera_features_score = 10.0
52
            score = score + 1
64
            else:
-
 
65
                additional_camera_features_score = len(additional_camera_features) 
53
    
66
    
54
    if struct.has_key("childrenslides") :
67
        if features.has_key("Secondary camera") :
55
        childrenslides = struct.get("childrenslides")
68
            secondary_camera_score = 10.0
56
 
69
 
57
        if childrenslides.has_key("Number of Cameras") :
70
        print "resolution_score" + `resolution_score`
58
            nfcs = childrenslides.get("Number of Cameras")
-
 
59
            if nfcs.has_key("features") :
71
        print "flash_score" + `flash_score`
60
                features = nfcs.get("features")
72
        print "image_formats_score" + `image_formats_score`
61
                
-
 
62
                # Number of Cameras > Primary camera : 1, 0
73
        print "secondary_camera_score" +  `secondary_camera_score`
63
                if features.has_key("Primary camera") :
74
        print "additional_camera_features_score" + `additional_camera_features_score`
64
                    score = score + 1
-
 
65
    
75
            
66
                # Number of Cameras > Secondary camera : 1, 0
76
        score = (30*resolution_score + 30*flash_score + 20*image_formats_score + 10*secondary_camera_score + 10*additional_camera_features_score) / 100
67
                if features.has_key("Secondary camera") :
-
 
68
                    score = score + 1
-
 
69
 
77
 
70
    return int(math.floor(score))
-
 
71
78
    return score
-
 
79
72
80