Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

import utils

def getscore(struct):
    
    score = 0.0
    ram_score = 0.0
    expansion_capacity_score = 0.0
    ram_type_score = 0.0
    clock_speed_score = 0.0
    
    if struct.has_key('features'):
        features = struct.get('features')
        
        if features.has_key("RAM"):
            ram = float(features.get('RAM')[0]) / (1024.0 * 1024.0)     #converting to GBs
            
            if ram <= 2.0:
                ram_score = 4
            elif ram > 2.0 and ram < 4.0:
                ram_score = 4 + (ram - 2.0) * 6.0 / 2
            else:
                ram_score = 10
            
        if features.has_key('Expansion capacity'):
            expansion_capacity = features.get('Expansion capacity')
            
            if expansion_capacity == 0:
                expansion_capacity_score = 0
            elif expansion_capacity == 2:
                expansion_capacity_score = 2.5
            elif expansion_capacity == 4:
                expansion_capacity_score = 5
            elif expansion_capacity == 8:
                expansion_capacity_score = 7.5
            elif expansion_capacity ==16:
                expansion_capacity_score = 10
            
        if features.has_key('RAM type'):
            ram_type = features.get('RAM type')
            ram_type_score = 10 if ram_type == 'DDR3' else 5
        
        if features.has_key('Memory clock speed'):
            pass                                    #TODO
        
    score = (70 * ram_score + 15 * expansion_capacity_score + 15 * ram_type_score) / 100
    return score

print "expSlide=" + `expSlide`

struct = utils.contentModel2Struct(expSlide, categoryObj)
print "struct=" + `struct`

score = getscore(struct)