Exemplo n.º 1
0
    def run(self, input: List(ContinuousVector())) -> ContinuousVector():
        input = np.vstack(input)

        if self.mode == "mean":
            return input.mean(axis=1)
        elif self.mode == "max":
            return input.max(axis=1)

        raise ValueError("Invalid mode: %s" % self.mode)
Exemplo n.º 2
0
 def run(
     self, input: Word(domain="general", language="spanish")
 ) -> ContinuousVector():
     """This method use Word2Vec of gensim for tranform a word in embedding vector.
     """
     try:
         return self.model.get_vector(input.lower())
     except KeyError:
         return np.zeros(400)
Exemplo n.º 3
0
 def run(self, input: List(ContinuousVector())) -> MatrixContinuousDense():
     return np.vstack(input)