Subversion Repositories SmartDukaan

Rev

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

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