def linearClassifier(featNames, optFile, workDir):

    megamNewWgtsFile = workDir + 'megam.weights.txt'

    mWF = open(megamNewWgtsFile, 'w')
    megam_scr = os.path.abspath( os.path.dirname(sys.argv[0]) )
    if megam_scr.endswith('/'): megam_scr = megam_scr + 'run_megam.sh'
    else: megam_scr = megam_scr + '/run_megam.sh'
    cmdArgs = ['sh', megam_scr, optFile]
    sys.stderr.write("Executing command: %s\n" % (' '.join( cmdArgs )))
    subprocess.call(cmdArgs, stdout=mWF)
    mWF.close()

    featWgts = []
    tempDict = {}
    mWF = open(megamNewWgtsFile, 'r')
    for wgt_line in mWF:
        wgt_line = wgt_line.strip()
        if not wgt_line.startswith('w_'): continue
        (f_name, f_wgt) = wgt_line.split(' ')
        tempDict[f_name] = float(f_wgt)
    mWF.close()

    for f_name in featNames:
        featWgts.append(tempDict[f_name])

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