Subversion Repositories SmartDukaan

Rev

Rev 6646 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6646 Rev 8045
Line 3... Line 3...
3
 
3
 
4
 
4
 
5
def getscore(struct):
5
def getscore(struct):
6
    
6
    
7
    score = 0.0
7
    score = 0.0
8
    builtin_score = 0.0
8
    builtin_exp_score = 2.0
9
    expansion_type_score = 0.0
9
    ram_score = 2.0
10
    expansion_capacity_score = 0.0
10
    builtin = 0
-
 
11
    exp = 0
11
    
12
    
12
    if struct.has_key("features") :
13
    if struct.has_key("features") :
13
        features = struct.get("features")
14
        features = struct.get("features")
14
    
15
    
15
        if features.has_key("Built-in") :
16
        if features.has_key("Built-in") :
16
            builtin = features.get("Built-in")
17
            builtin = features.get("Built-in")
17
            
18
            
18
            if len(builtin) > 0 :
19
            if len(builtin) > 0 :
19
                builtin = float(builtin[0])
20
                builtin = float(builtin[0])
20
                print "builtin=" + `builtin`
-
 
21
                
-
 
22
                if builtin <= 1024:
-
 
23
                    builtin_score = 0.0
-
 
24
                    
-
 
25
                elif builtin < 1024*128:
-
 
26
                    builtin_score = 1.0
-
 
27
                     
-
 
28
                elif builtin >= 64*1024*1024 :
-
 
29
                    builtin_score = 10.0 
-
 
30
                
-
 
31
                else :
-
 
-
 
21
 
32
                    builtin_score = log(builtin/(1024*64), 2)
-
 
33
                      
-
 
34
        # REVISIT
-
 
35
        # Expansion Type : microSD-2, others-1
-
 
36
        if features.has_key("Expansion type") :
-
 
37
            expansion_type = features.get("Expansion type")
-
 
38
            if len(expansion_type) > 0 :
-
 
39
                expansion_type = expansion_type[0]
-
 
40
                if expansion_type ==  "MicroSD card" :
-
 
41
                    expansion_type_score = 10
-
 
42
                else :
-
 
43
                    expansion_type_score = 0.0
-
 
44
        # Expansion Capacity : 2, 4, 8, 16, 32
22
        # Expansion Capacity : 2, 4, 8, 16, 32
45
        if features.has_key("Expansion capacity") :
23
        if features.has_key("Expansion capacity") :
46
            expansion_capacity = features.get("Expansion capacity")
24
            expansion_capacity = features.get("Expansion capacity")
47
            
25
            
48
            if len(expansion_capacity) > 0 :
26
            if len(expansion_capacity) > 0 :
49
                expansion_capacity = float(expansion_capacity[0])
27
                exp = float(expansion_capacity[0])
50
                print "expansion_capacity=" + `expansion_capacity`
28
                print "expansion_capacity=" + `expansion_capacity`
51
                 
29
        
52
                if expansion_capacity < 2*1024*1024 :
30
        total_memory = 3*builtin + exp
53
                    expansion_capacity_score = 0.0  
31
        if total_memory > 4*1024*1024:
54
                    
-
 
55
                elif expansion_capacity >= 32*1024*1024 :
32
            if total_memory >= 128*1024*1024:
56
                    expansion_capacity_score = 10
33
                builtin_exp_score = 10.0
57
                
-
 
58
                else :
34
            else:
59
                    expansion_capacity_score = (sqrt(32*1024*1024) - sqrt(expansion_capacity)) / (sqrt(32*1024*1024) - sqrt(2*1024)) * 10
35
                builtin_exp_score = 2.0 + 1.6 * log(total_memory/(4*1024*1024), 2)
60
 
36
 
-
 
37
        if features.has_key("RAM") :
-
 
38
            ram = features.get("RAM")
-
 
39
            ram = float(ram[0])
-
 
40
            if ram > 1024*64:
61
    print "builtin_score" + `builtin_score`
41
                if ram >= 1024*1024*2:
-
 
42
                    ram_score = 10.0
-
 
43
                else:
-
 
44
                    ram_score = 2.0 + 1.6*log(ram_score/(64*1024), 2)
62
    print "expansion_type_score" + `expansion_type_score`
45
    print "builtin_exp_score" + `builtin_exp_score`
63
    print "expansion_capacity_score" + `expansion_capacity_score`
46
    print "ram_score" + `ram_score`
-
 
47
    
64
    
48
    
65
    score = (70*builtin_score +  + 30*expansion_capacity_score)/100
49
    score = (60*builtin_exp_score +  + 40*ram_score)/100
66
    return score
50
    return score