Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
71 naveen 1
def getscore(struct):
1915 rajveer 2
 
3
    score = 0.0
4
    file_formats_score = 0.0
5
    streaming_score = 0.0
8045 amit.gupta 6
    recording_score = 0.0
5475 amit.gupta 7
    hd_video_playback = 0.0
1915 rajveer 8
 
2663 rajveer 9
    category = struct.get("category")
2655 rajveer 10
 
1915 rajveer 11
    features = struct.get("features")
12
 
13
    if features.has_key("File formats") :
14
        file_formats = features.get("File formats")
15
        number_of_file_formats = len(file_formats)
1936 rajveer 16
        if number_of_file_formats == 1 :
1915 rajveer 17
            file_formats_score = 4.0
8079 amit.gupta 18
        elif number_of_file_formats >= 4 :
1915 rajveer 19
            file_formats_score = 10.0
20
        else :
8079 amit.gupta 21
            file_formats_score = 3*number_of_file_formats
1915 rajveer 22
 
23
    if features.has_key("Streaming") :
24
        streaming_score = 10.0
2655 rajveer 25
 
26
    if category == "Tablets" :
27
        if features.has_key("HD video playback") :
5475 amit.gupta 28
           hd_video_playback = 10.0
2655 rajveer 29
    else :
8045 amit.gupta 30
        if features.has_key("Video recording") :
31
            recording = features.get("Video recording")
32
            if len(recording) > 0:
33
                print "recording :" + `recording`
34
                recording = recording[0]
35
                if recording == "Yes":
8079 amit.gupta 36
                    recording_score = 4.0
8045 amit.gupta 37
                elif recording == "720p HD video recording":
8079 amit.gupta 38
                    recording_score = 7.0
8045 amit.gupta 39
                elif recording == "1080p Full HD video recording":
40
                    recording_score = 10.0
41
 
5475 amit.gupta 42
        if features.has_key("HD Video playback") :
43
            hd_video_playback = 10.0
1915 rajveer 44
 
5475 amit.gupta 45
    if category == "Tablets" :
46
        score = (50*file_formats_score + 25*streaming_score + 25*hd_video_playback)/100
47
    else : 
8045 amit.gupta 48
        score = (40*file_formats_score + 30*recording_score + 30*hd_video_playback)/100
5475 amit.gupta 49
 
1915 rajveer 50
 
51
    print "file_formats_score" + `file_formats_score`
5475 amit.gupta 52
    print "hd_video_playback" + `hd_video_playback`
8045 amit.gupta 53
    print "recording_score" + `recording_score`
1915 rajveer 54
 
8045 amit.gupta 55
    return score