Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4036 varun.gupt 1
import utils
2
 
3
def getscore(struct):
4
 
5
    score = 0.0
6
    weight_score = 0.0
7
    size_score = 0.0
8
 
9
    if struct.has_key('features'):
10
        features = struct.get('features')
11
 
12
        if features.has_key("Weight"):
13
            weight = features.get('Weight')
14
 
15
            if weight <= 1.5:
16
                weight_score = 10.0
17
            elif weight > 1.5 and weight <= 2.5:
18
                weight_score = 10.0 - (weight - 1.5) * 6
19
            else:
20
                weight_score = 4.0
21
 
22
        if features.has_key('Size'):
23
            size = features.get('Size')
24
 
25
            if len(size) > 2:
26
                thickness = float(size[2])
27
 
28
                if thickness <= 20.0:
29
                    size_score = 10.0
30
                elif thickness > 20.0 and thickness < 40.0:
31
                    size_score = 10 - (thickness - 20.0) * 6 / 20
32
                else:
33
                    size_score = 4.0
34
 
35
    score = (60 * weight_score + 40 * size_score) / 100
36
    return score
37
 
38
 
39
print "expSlide=" + `expSlide`
40
 
41
struct = utils.contentModel2Struct(expSlide, categoryObj)
42
print "struct=" + `struct`
43
 
44
score = getscore(struct)