'Yields the document vector, a dictionary of (word, relevance)-items from the document.
The relevance is tf, tf * idf, infogain or binary if the document is part of a Model,
based on the value of Model.weight (TF, TFIDF, IG, GR, BINARY, None).
The document vector is used to calculate similarity between two documents,
for example in a clustering or classification algorithm.'

@property
def vector(self):

    if (not self._vector):
        w = getattr(self.model, 'weight', TF)
        if (w not in (TF, TFIDF, IG, INFOGAIN, GR, GAINRATIO, BINARY)):
            f = (lambda w: float(self._terms[w]))
            w = None
        if (w == BINARY):
            f = (lambda w: int((self._terms[w] > 0)))
        if (w == TF):
            f = self.tf
        if (w == TFIDF):
            f = self.tf_idf
        if (w in (IG, INFOGAIN)):
            f = self.model.ig
        if (w in (GR, GAINRATIO)):
            f = self.model.gr
        self._vector = Vector(((w, f(w)) for w in self.terms), weight=w)
    return self._vector
