Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

import utils

def getscore(struct):
    
    score = 0.0
    
    if struct.has_key('features'):
        features = struct.get('features')
        if features.has_key('Web cam'):
            if `features.get('Web cam')[0]`.find('VGA') > -1 or `features.get('Web cam')[0]`.find('0.3') > -1 or `features.get('Web cam')[0]`.find('1.3')> -1 :
                score += 20
            else :
                score += 30 
        if features.has_key('Pointing device'):
            score +=15.0
            if features.has_key('Pointing device_fft'):
                for fft in features.get('Pointing device_fft'):
                    fft = fft.encode()
                    if fft.find('multi') > -1 or fft.find('Multi') > -1:
                        if fft.find('touch') > -1 or fft.find('Touch')> -1:
                            score += 5.0
                            break
                           
        if features.has_key('Built-in speaker'):
            score += 15.0
            if len(features.get('Built-in speaker')[0]) > -1:
                score += 5.0
        if features.has_key('Dedicated keys'):
            score += 10.0
        if features.has_key('Biometric security'):
            bio_score = len(features.get('Biometric security'))*10.0
            if bio_score > 20.0:
                bio_score = 20.0
            score += bio_score
    
    return score/10.0


print "expSlide=" + `expSlide`

struct = utils.contentModel2Struct(expSlide, categoryObj)
print "struct=" + `struct`

score = getscore(struct)