Subversion Repositories SmartDukaan

Rev

Rev 4569 | Rev 5204 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4036 varun.gupt 1
import utils
2
 
3
def getMaxValFromDict(dictionary):
4
 
5
    max = None
6
 
7
    for key, val in dictionary.iteritems():
4569 varun.gupt 8
        if max is None or max < val:    max = val
4036 varun.gupt 9
 
10
    return max * 1.0
11
 
12
def getBenchmarkScore(model):
13
    processor_benchmarks = {
5173 amit.gupta 14
        "2310M" :    2619.0,
15
        "2330M " :    2729.0,
16
        "2350M" :    2932.0,
17
        "2410M" :    3362.0,
18
        "2430M " :    3456.0,
19
        "2450M" :    3566.0,
20
        "2467M" :    205.0,
21
        "2557M" :    224.0,
22
        "2630QM" :    6345.0,
23
        "2640M" :    4065.0,
24
        "2670QM" :    6811.0,
25
        "2720QM" :    6973.0,
26
        "2760QM" :    7595.0,
27
        "370M" :    2238.0,
28
        "380M" :    2328.0,
29
        "380UM " :    1317.0,
30
        "3400M" :    2976.0,
31
        "A6-3400M" :    2976.0,
32
        "AMD C60" :    565.0,
33
        "C60" :    565.0,
34
        "B800" :    1365.0,
35
        "B940" :    1880.0,
36
        "B950" :    1959.0,
37
        "B960" :    2090.0,
38
        "E-300" :    597.0,
39
        "E-350" :    727.0,
40
        "E-450" :    743.0,
41
        "2435M" :    3336.0,
42
        "2367M" :    1844.0,
43
        "i3-2367M" :    1844.0,
44
        "N2600" :    590.0,
45
        "N2800" :    723.0,
46
        "N455" :    320.0,
47
        "N550" :    569.0,
48
        "N570" :    639.0,
49
        "K325" :    780.0,
50
        "Neo K325" :    780.0,
51
        "P6200" :    1663.0,
52
        "T4500" :    1575.0,
53
        "T6570" :    1345.0
4036 varun.gupt 54
    }
55
    max_score = getMaxValFromDict(processor_benchmarks)
5173 amit.gupta 56
    score = max_score/2
4036 varun.gupt 57
 
58
    for processor, benchmark_score in processor_benchmarks.iteritems():
59
        if(processor.lower().find(model.lower()) > -1):
5173 amit.gupta 60
            if benchmark_score <= 0.2*max_score:
61
                score = 0.2*max_score
62
            else :
63
                score = benchmark_score
4036 varun.gupt 64
 
65
    return (score * 10.0) / max_score
66
 
67
def getChipsetScore(chipset):
68
    chipset_scores = {
69
            'Intel HM65': 10,
70
            'Intel HM 57': 9.5,
71
            'Intel HM55': 9,
72
            'AMD M888G': 8.5,
73
            'Intel 45': 8,
74
            'Intel NM10': 7
75
    }
76
    for chipset_name, score in chipset_scores.iteritems():
77
        if chipset_name.lower().find(chipset) > -1 or chipset.find(chipset_name.lower()) > -1: return score
78
 
79
 
80
def getscore(struct):
81
    score = 0.0
82
    model_score = 0.0
83
 
84
    if struct.has_key('features'):
85
        features = struct.get('features')
86
 
87
        if features.has_key('Processor model'):
88
            model = features.get('Processor model')
89
            model_score = getBenchmarkScore(str(model[0]))
90
    return model_score
4569 varun.gupt 91
 
4036 varun.gupt 92
print "expSlide=" + `expSlide`
93
 
94
struct = utils.contentModel2Struct(expSlide, categoryObj)
95
print "struct=" + `struct`
96
 
97
score = getscore(struct)