def train(self, doc):
        """
        takes training data and a path and creates an svm model
        """

        model_file = '%ssvm_model' %self.path

        ## need integer dictionary for features
        sys.stderr.write('training. making feat dict... ')
        feat_list = set()
        frag = doc.frag
        while frag:
            feats = [f+'_'+v for f,v in frag.features.items()]
            for feat in feats: feat_list.add(feat)
            frag = frag.next
        self.feats = dict(zip(feat_list, range(1,len(feat_list)+1)))

        ## training data file
        sys.stderr.write('writing... ')
        lines = []
        frag = doc.frag
        while frag:
            if frag.label == None: sbd_util.die('expecting labeled data [%s]' %frag)
            elif 0.5 > frag.label: svm_label = '+1'
            elif frag.label < 0.5: svm_label = '-1'
            else: continue
            line = '%s ' %svm_label
            feats = [f+'_'+v for f,v in frag.features.items()]
            svm_feats = [self.feats[f] for f in feats]
            svm_feats.sort(lambda x,y: x-y)
            line += ' '.join(['%d:1' %x for x in svm_feats])
            lines.append(line)
            frag = frag.next

        unused, train_file = tempfile.mkstemp()
        fh = open(train_file, 'w')
        fh.write('\n'.join(lines) + '\n')
        fh.close()
    
        ## train an svm model
        sys.stderr.write('running svm... ')
        options = '-c 1 -v 0'
        cmd = '%s %s %s %s' %(SVM_LEARN, options, train_file, model_file)
        os.system(cmd)
        sys.stderr.write('done!\n')

        ## clean up
        os.remove(train_file)
dataset/ETHPy150Open daeilkim/refinery/refinery/lib/sbd.py/SVM_Model.train/swapped operands of `>`