Subversion Repositories SmartDukaan

Rev

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

Rev 1936 Rev 2655
Line 3... Line 3...
3
    score = 0.0
3
    score = 0.0
4
    
4
    
5
    weight_score = 0.0
5
    weight_score = 0.0
6
    thickness_score = 0.0
6
    thickness_score = 0.0
7
    
7
    
-
 
8
    category = struct.has_key("category")
-
 
9
    max_weight = 250
-
 
10
    min_weight = 60
-
 
11
    max_thickness = 20
-
 
12
    min_thickness = 9
-
 
13
    
-
 
14
    if category == "Tablets":
-
 
15
        max_weight = 740
-
 
16
        min_weight = 400
-
 
17
        max_thickness = 13
-
 
18
        min_thickness = 10
-
 
19
        
8
    if struct.has_key("features") :
20
    if struct.has_key("features") :
9
        features = struct.get("features")
21
        features = struct.get("features")
10
 
22
 
11
        # Weight : >250-10, <=60-10, others linear
23
        # Weight : >250-10, <=60-10, others linear
12
        if features.has_key("Weight") :
24
        if features.has_key("Weight") :
Line 14... Line 26...
14
            
26
            
15
            if len(weight) > 0 :
27
            if len(weight) > 0 :
16
                weight = float(weight[0])
28
                weight = float(weight[0])
17
                print "weight=" + `weight`
29
                print "weight=" + `weight`
18
                
30
                
19
                if weight > 250 :
31
                if weight > max_weight :
20
                    weight_score = 0
32
                    weight_score = 0
21
                
33
                
22
                elif weight <= 60 :
34
                elif weight <= min_weight :
23
                    weight_score = 10
35
                    weight_score = 10
24
 
36
 
25
                else :
37
                else :
26
                    weight_score = 10 - (weight - 60) / (250 - 60) * 10
38
                    weight_score = 10 - (weight - min_weight) / (max_weight - min_weight) * 10
27
    
39
    
28
        # Size : Thickness <=10-4, <=12-3, <=14-2, >14-1
40
        # Size : Thickness <=10-4, <=12-3, <=14-2, >14-1
29
        if features.has_key("Size") :
41
        if features.has_key("Size") :
30
            size = features.get("Size")
42
            size = features.get("Size")
31
            
43
            
32
            if len(size) > 2 :
44
            if len(size) > 2 :
33
                thickness = float(size[2])
45
                thickness = float(size[2])
34
                print "thickness=" + `thickness`
46
                print "thickness=" + `thickness`
35
                
47
                
36
                if thickness <= 9 :
48
                if thickness <= min_thickness :
37
                    thickness_score = 10
49
                    thickness_score = 10
38
                
50
                
39
                elif thickness > 20 :
51
                elif thickness > max_thickness :
40
                    thickness_score = 0
52
                    thickness_score = 0
41
 
53
 
42
                else :
54
                else :
43
                    thickness_score = 10 - (thickness - 9) / (20 - 9) * 10
55
                    thickness_score = 10 - (thickness - min_thickness) / (max_thickness - max_thickness) * 10
44
    
56
    
45
    score = (weight_score*50 + thickness_score*50)/100.0
57
    score = (weight_score*50 + thickness_score*50)/100.0
46
    
58
    
47
    return score
59
    return score