Subversion Repositories SmartDukaan

Rev

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

import utils

def getMaxValFromDict(dictionary):
    
    max = None
    
    for key, val in dictionary.iteritems():
        if max is None or max < val:    max = val
    
    return max * 1.0

def getBenchmarkScore(model):
    processor_benchmarks = {
        "2310M" :    2619.0,
        "2330M" :    2729.0,
        "2350M" :    2932.0,
        "2410M" :    3362.0,
        "2430M" :    3456.0,
        "2450M" :    3573.0,
        "2467M" :    2413.0,
        "2557M" :    2601.0,
        "2630QM" :    6345.0,
        "2640M" :    4065.0,
        "2670QM" :    6811.0,
        "2720QM" :    6973.0,
        "2760QM" :    7595.0,
        "370M" :    2238.0,
        "380M" :    2328.0,
        "380UM" :    1317.0,
        "3400M" :    2976.0,
        "A6-3400M" :    2976.0,
        "AMD C60" :    565.0,
        "C60" :    565.0,
        "B800" :    1365.0,
        "B940" :    1880.0,
        "B950" :    1959.0,
        "B960" :    2090.0,
        "E-300" :    597.0,
        "E-350" :    727.0,
        "E-450" :    743.0,
        "2435M" :    3336.0,
        "2367M" :    1844.0,
        "i3-2367M" :    1844.0,
        "N2600" :    590.0,
        "N2800" :    723.0,
        "N455" :    320.0,
        "N550" :    569.0,
        "N570" :    639.0,
        "K325" :    780.0,
        "Neo K325" :    780.0,
        "P6200" :    1663.0,
        "T4500" :    1575.0,
        "T6570" :    1345.0
    }
    max_score = getMaxValFromDict(processor_benchmarks)
    score = 0.0   
    for processor, benchmark_score in processor_benchmarks.iteritems():
        if(model.lower().find((processor.lower())) > -1):
            score = benchmark_score
    
    return (score * 10.0) / max_score

def getChipsetScore(chipset):
    chipset_scores = {
            'Intel HM65': 10,
            'Intel HM 57': 9.5,
            'Intel HM55': 9,
            'AMD M888G': 8.5,
            'Intel 45': 8,
            'Intel NM10': 7
    }
    for chipset_name, score in chipset_scores.iteritems():
        if chipset_name.lower().find(chipset) > -1 or chipset.find(chipset_name.lower()) > -1: return score


def getscore(struct):
    score = 0.0
    model_score = 0.0
    
    if struct.has_key('features'):
        features = struct.get('features')
        
        if features.has_key('Processor model'):
            model = features.get('Processor model')
            model_score = getBenchmarkScore(str(model[0]))
    return model_score

print "expSlide=" + `expSlide`

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

score = getscore(struct)