def svmClassifier(featNames, optFile, workDir):

    modelFile = workDir + 'svmrank.weights.txt'
    svnrank_scr = os.path.abspath( os.path.dirname(sys.argv[0]) )
    if svnrank_scr.endswith('/'): svnrank_scr = svnrank_scr + 'run_svmrank.sh'
    else: svnrank_scr = svnrank_scr + '/run_svmrank.sh'
    cmdArgs = ['sh', svnrank_scr, optFile, modelFile]
    sys.stderr.write("Executing command: %s\n" % (' '.join( cmdArgs )))
    subprocess.call(cmdArgs)

    featWgts = [0.0 for x in featNames]
    mF = open(modelFile, 'r')
    for wgt_line in mF:
        wgt_line = wgt_line.strip()
        if not wgt_line.endswith('#'): continue

        (alpha_w, _) = wgt_line.split(' ', 1)
        alpha_w = float(alpha_w)
        for feat_wgt_pair in wgt_line.split(' '):
            if feat_wgt_pair.find(':') == -1: continue
            (feat, wgt) = feat_wgt_pair.split(':')
            feat_id = int(feat) - 1
            featWgts[feat_id] = alpha_w * float(wgt)
    mF.close()

    return featWgts
dataset/ETHPy150Open sfu-natlang/Kriya/src/Kriya-Decoder/mert-scripts/PRO.py/svmClassifier/original