'Trains the classifier with the given document of the given type (i.e., class).
A document can be a Document, Vector, dict, list or string.
If no type is given, Document.type will be used instead.'

def train(self, document, type=None):

    (type, vector) = self._vector(document, type=type)
    self._classes[type] = (self._classes.get(type, 0) + 1)
    self._likelihood.setdefault(type, {})
    self._cache.pop(type, None)
    for (f, w) in vector.items():
        if (self._method in (BINARY, BINOMIAL, BERNOUILLI)):
            w = 1
        self._features[f] = (self._features.get(f, 0) + 1)
        self._likelihood[type][f] = (self._likelihood[type].get(f, 0) + w)
