Subversion Repositories SmartDukaan

Rev

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

Rev 323 Rev 1915
Line 1... Line 1...
1
def getscore(struct) :
1
def getscore(struct) :
-
 
2
    
2
    score = 0
3
    score = 0.0
-
 
4
    music_formats_score = 0.0
-
 
5
    ear_phone_score = 0.0
-
 
6
    speaker_phone_score = 0.0
-
 
7
    fm_radio_score = 0.0
-
 
8
    internet_radio_score = 0.0
-
 
9
    
3
    if not struct.has_key("features") :
10
    if not struct.has_key("features") :
4
        return score
11
        return score
5
    
12
    
6
    features = struct.get("features")
13
    features = struct.get("features")
7
    
14
    
8
    # REVISIT - May be we should count supported formats
-
 
9
    if features.has_key("Ringtone Types") :
-
 
10
        score = score + 1 
-
 
11
    
-
 
12
    # REVISIT - May be we should count supported formats
-
 
13
    if features.has_key("Music Formats") :
15
    if features.has_key("Music formats") :
14
        score = score + 1 
-
 
15
        
-
 
16
    if features.has_key("FM Radio") :
-
 
17
        score = score + 1 
-
 
18
        
-
 
19
    if features.has_key("Headset") :
16
        music_formats = features.get("Music formats")
20
        score = score + 1 
17
        number_of_music_formats = len(music_formats)
21
 
-
 
22
    if features.has_key("Album art") :
-
 
23
        score = score + 1 
18
        music_formats_score = number_of_music_formats
24
 
19
 
-
 
20
    if features.has_key("Earphone") :
-
 
21
        ear_phone_score = 10.0
-
 
22
                
-
 
23
    if features.has_key("FM radio") :
-
 
24
        fm_radio_score = 10.0 
-
 
25
        
25
    if features.has_key("Speaker phone") :
26
    if features.has_key("Speaker phone") :
26
        score = score + 1 
27
        speaker_phone_score = 10.0 
27
 
28
 
28
    if features.has_key("Internet Radio") :
29
    if features.has_key("Internet radio") :
29
        score = score + 2 
30
        internet_radio_score = 10.0
30
 
31
 
-
 
32
    score = (30*music_formats_score + 20*ear_phone_score + 20*speaker_phone_score + 20*fm_radio_score + 10*internet_radio_score)/100
-
 
33
 
-
 
34
    print "music_formats_score" + str(music_formats_score)
-
 
35
    print "ear_phone_score" + str(ear_phone_score)
-
 
36
    print "speaker_phone_score" + str(speaker_phone_score)
-
 
37
    print "fm_radio_score" + str(fm_radio_score)
-
 
38
    print "internet_radio_score" + str(internet_radio_score)
-
 
39
    
31
    return score
40
    return score