MCPcopy Index your code
hub / github.com/clips/pattern / _vector

Method _vector

pattern/vector/__init__.py:1761–1779  ·  view source on GitHub ↗

Returns a (type, Vector)-tuple for the given document. If the document is part of a LSA-reduced model, returns the LSA concept vector. If the given type is None, returns document.type (if a Document is given).

(self, document, type=None)

Source from the content-addressed store, hash-verified

1759 return self.baseline
1760
1761 def _vector(self, document, type=None):
1762 """ Returns a (type, Vector)-tuple for the given document.
1763 If the document is part of a LSA-reduced model, returns the LSA concept vector.
1764 If the given type is None, returns document.type (if a Document is given).
1765 """
1766 if isinstance(document, Document):
1767 if type is None:
1768 type = document.type
1769 if document.model and document.model.lsa:
1770 return type, document.model.lsa[document.id] # LSA concept vector.
1771 return type, document.vector
1772 if isinstance(document, Vector):
1773 return type, document
1774 if isinstance(document, dict):
1775 return type, Vector(document)
1776 if isinstance(document, (list, tuple)):
1777 return type, Document(document, filter=None, stopwords=True).vector
1778 if isinstance(document, basestring):
1779 return type, Document(document, filter=None, stopwords=True).vector
1780
1781 @classmethod
1782 def k_fold_cross_validation(cls, corpus=[], k=10, **kwargs):

Callers 5

trainMethod · 0.95
trainMethod · 0.80
classifyMethod · 0.80
classifyMethod · 0.80
_classifyMethod · 0.80

Calls 2

VectorClass · 0.70
DocumentClass · 0.70

Tested by

no test coverage detected