Subversion Repositories SmartDukaan

Rev

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

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