Subversion Repositories SmartDukaan

Rev

Rev 4036 | Details | Compare with Previous | 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
    ram_score = 0.0
7
    expansion_capacity_score = 0.0
8
    ram_type_score = 0.0
9
    clock_speed_score = 0.0
10
 
11
    if struct.has_key('features'):
12
        features = struct.get('features')
13
 
14
        if features.has_key("RAM"):
15
            ram = float(features.get('RAM')[0]) / (1024.0 * 1024.0)     #converting to GBs
16
 
17
            if ram <= 2.0:
18
                ram_score = 4
19
            elif ram > 2.0 and ram < 4.0:
20
                ram_score = 4 + (ram - 2.0) * 6.0 / 2
21
            else:
5173 amit.gupta 22
                ram_score = 10.0
23
 
4036 varun.gupt 24
        if features.has_key('Expansion capacity'):
5173 amit.gupta 25
            #convert to GBs
26
            expansion_capacity = float(features.get('Expansion capacity')[0])/(1024.0*1024.0)
4036 varun.gupt 27
            if expansion_capacity == 0:
28
                expansion_capacity_score = 0
29
            elif expansion_capacity == 2:
30
                expansion_capacity_score = 2.5
31
            elif expansion_capacity == 4:
32
                expansion_capacity_score = 5
33
            elif expansion_capacity == 8:
34
                expansion_capacity_score = 7.5
35
            elif expansion_capacity ==16:
5173 amit.gupta 36
                expansion_capacity_score = 10.0
4036 varun.gupt 37
 
38
        if features.has_key('RAM type'):
5173 amit.gupta 39
            ram_type = features.get('RAM type')[0].encode()
4036 varun.gupt 40
            ram_type_score = 10 if ram_type == 'DDR3' else 5
41
        if features.has_key('Memory clock speed'):
42
            pass                                    #TODO
43
 
5173 amit.gupta 44
    score = (70 * ram_score + 10 * expansion_capacity_score + 20 * ram_type_score) / 100.0
4036 varun.gupt 45
    return score
46
 
47
print "expSlide=" + `expSlide`
48
 
49
struct = utils.contentModel2Struct(expSlide, categoryObj)
50
print "struct=" + `struct`
51
 
52
score = getscore(struct)