Subversion Repositories SmartDukaan

Rev

Rev 3448 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8045 amit.gupta 1
import math
77 naveen 2
def getscore(struct) :
3
 
1915 rajveer 4
    score = 0.0
8045 amit.gupta 5
    communication_facilities_score = 0.0
1915 rajveer 6
    twog_network_score = 0.0
7
    threeg_network_score = 0.0
8
    multiple_sim_score = 0.0
77 naveen 9
 
10
    if struct.has_key("features") :
11
        features = struct.get("features")
8045 amit.gupta 12
        if features.has_key("Communication facilities") :
13
            communication_facilities = features.get("Communication facilities")
14
            communication_facilities_score = min(3,len(communication_facilities))*3.3
77 naveen 15
 
1915 rajveer 16
        if features.has_key("2G network") :
17
            twog_network = features.get("2G network")
18
            if len(twog_network) > 0 :
19
                twog_network = twog_network[0]
20
                print "2G Network=" + `twog_network`
21
                if twog_network.find("Quadband") > -1 :
22
                    twog_network_score = 9
23
                elif twog_network.find("Triband") > -1 :
24
                    twog_network_score = 7
25
                elif twog_network.find("Dualband") > -1 :
26
                    twog_network_score = 5
77 naveen 27
 
1915 rajveer 28
        if features.has_key("3G network") :
29
            threeg_network_score = 10
77 naveen 30
 
1915 rajveer 31
        if features.has_key("Multiple SIM") :
32
            multiple_sim_score = 10
77 naveen 33
 
8045 amit.gupta 34
    score = (15*communication_facilities_score + 40*twog_network_score + 30*threeg_network_score + round(15*multiple_sim_score))/100.0    
1915 rajveer 35
 
36
    print "twog_network_score" + str(twog_network_score)
37
    print "threeg_network_score" + str(threeg_network_score)
38
    print "multiple_sim_score" + str(multiple_sim_score)
39
 
8045 amit.gupta 40
    return score