def classify(self, doc, verbose=False):

        model_file = '%ssvm_model' %self.path
        if not self.feats: sbd_util.die('Incomplete model')
        if not os.path.isfile(model_file): sbd_util.die('no model [%s]' %model_file)

        ## testing data file
        if verbose: sys.stderr.write('SVM classifying... ')
        lines = []
        frag = doc.frag
        while frag:
            if frag.label == None: svm_label = '0'
            elif frag.label: svm_label = '+1'
            else: svm_label = '-1'
            line = '%s ' %svm_label
            feats = [f+'_'+v for f,v in frag.features.items()]
            svm_feats = [self.feats[f] for f in feats if f in self.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

        #print "!----!",get_open_fds()
        #unused, test_file = tempfile.mkstemp()
        test_file = "tmp1"
        fh = open(test_file, 'w')
        fh.write('\n'.join(lines) + '\n')
        fh.close()
        #print "!----!",get_open_fds()

    
        #unused, pred_file = tempfile.mkstemp()
        pred_file = "tmp2"
        options = '-v 0'
        cmd = '%s %s %s %s %s' %(SVM_CLASSIFY, options, test_file, model_file, pred_file)
        os.system(cmd)

        ## get predictions
        total = 0
        pf = open(pred_file,'r')
        #print pf
        preds = map(float, pf.read().splitlines())
        frag = doc.frag
        while frag:
            frag.pred = sbd_util.logit(preds[total])
            frag = frag.next
            total += 1

        ## clean up
        pf.close()
        os.remove(test_file)
        os.remove(pred_file)
        
        if verbose: sys.stderr.write('done!\n')
dataset/ETHPy150Open daeilkim/refinery/refinery/lib/sbd.py/SVM_Model.classify/original