def train(self, doc):

        sys.stderr.write('training nb... ')
        feats = collections.defaultdict(sbd_util.Counter)
        totals = sbd_util.Counter()

        frag = doc.frag
        while frag:
            for feat, val in frag.features.items():
                feats[frag.label][feat + '_' + val] += 1
            totals[frag.label] += len(frag.features)
            frag = frag.next

        ## add-1 smoothing and normalization
        sys.stderr.write('smoothing... ')
        smooth_inc = 0.1
        all_feat_names = set(feats[True].keys()).union(set(feats[False].keys()))
        for label in [0,1]:
            totals[label] += (len(all_feat_names) * smooth_inc)
            for feat in all_feat_names:
                feats[label][feat] += smooth_inc
                feats[label][feat] /= totals[label]
                self.feats[(label, feat)] = feats[label][feat]
            feats[label]['<prior>'] = totals.totalCount() / totals[label]
            self.feats[(label, '<prior>')] = feats[label]['<prior>']

        sys.stderr.write('done!\n')
dataset/ETHPy150Open daeilkim/refinery/refinery/lib/sbd.py/NB_Model.train/swapped operands of `/`