Subversion Repositories SmartDukaan

Rev

Rev 323 | Rev 1936 | 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
def getscore(struct):
1
def getscore(struct):
2
    
2
    
3
    score = 0
3
    score = 0.0
-
 
4
    
-
 
5
    weight_score = 0.0
-
 
6
    thickness_score = 0.0
4
    
7
    
5
    if struct.has_key("features") :
8
    if struct.has_key("features") :
6
        features = struct.get("features")
9
        features = struct.get("features")
7
 
10
 
8
        # Weight : <=100-3, <=150-2, >150-1
11
        # Weight : >250-10, <=60-10, others linear
9
        if features.has_key("Weight") :
12
        if features.has_key("Weight") :
10
            weight = features.get("Weight")
13
            weight = features.get("Weight")
11
            
14
            
12
            if len(weight) > 0 :
15
            if len(weight) > 0 :
13
                weight = float(weight[0])
16
                weight = float(weight[0])
14
                print "weight=" + `weight`
17
                print "weight=" + `weight`
15
                
18
                
16
                if weight <= 100 :
19
                if weight > 250 :
17
                    score += 3
20
                    weight_score = 0
18
                
21
                
19
                elif weight <= 150 :
22
                elif weight <= 60 :
20
                    score += 2
23
                    weight_score = 10
21
 
24
 
22
                elif weight > 150 :
25
                else :
23
                    score += 1
26
                    weight_score = 10 - (weight - 60) / (250 - 60) * 10
24
    
27
    
25
        # REVISIT
-
 
26
        # Size : Thickness <=10-4, <=12-3, <=14-2, >14-1
28
        # Size : Thickness <=10-4, <=12-3, <=14-2, >14-1
27
        if features.has_key("Size") :
29
        if features.has_key("Size") :
28
            size = features.get("Size")
30
            size = features.get("Size")
29
            
31
            
30
            if len(size) > 2 :
32
            if len(size) > 2 :
31
                thickness = float(size[2])
33
                thickness = float(size[2])
32
                print "thickness=" + `thickness`
34
                print "thickness=" + `thickness`
33
                
35
                
34
                if thickness <= 10 :
36
                if thickness <= 9 :
35
                    score += 4
37
                    thickness_score = 10
36
                
38
                
37
                elif thickness <= 12 :
39
                elif thickness > 20 :
38
                    score += 3
40
                    thickness_score = 0
39
 
41
 
40
                elif thickness <= 14 :
-
 
41
                    score += 2
-
 
42
                    
42
                else :
43
                elif thickness > 14 :
43
                    thickness_score = 10 - (thickness - 9) / (20 - 9)
44
                    score += 1
-
 
45
    
-
 
46
    # REVISIT
-
 
47
    # Form Factor
-
 
48
    
44
    
49
    # REVISIT
-
 
50
    # Color
45
    score = (weight_score*50 + thickness_score*50)/100
51
    
46
    
52
    return score
47
    return score