Returns a Vector dict of (word, 0.0)-items from the vector space model. It includes all words from all documents (i.e. it is the dimension of the vector space). Model.vector(document) yields a vector with the feature weights of the given document.
(self)
| 978 | |
| 979 | @property |
| 980 | def vector(self): |
| 981 | """ Returns a Vector dict of (word, 0.0)-items from the vector space model. |
| 982 | It includes all words from all documents (i.e. it is the dimension of the vector space). |
| 983 | Model.vector(document) yields a vector with the feature weights of the given document. |
| 984 | """ |
| 985 | # Notes: |
| 986 | # 1) Model.vector is the dictionary of all (word, 0.0)-items. |
| 987 | # 2) Model.vector(document) returns a copy with the document's word frequencies. |
| 988 | # This is the full vector, as opposed to the sparse Document.vector. |
| 989 | # Words in a document that are not in the model are ignored, |
| 990 | # i.e., the document was not in the model, this can be the case in Model.search(). |
| 991 | # See: Vector.__call__(). |
| 992 | if not self._vector: |
| 993 | self._vector = Vector((w, 0.0) for w in chain(*(d.terms for d in self.documents))) |
| 994 | return self._vector |
| 995 | |
| 996 | @property |
| 997 | def vectors(self): |