import WordEmbeddingMixins from 'causal-net/packages/causality-representation/src/wordEmbedding.mixins.js'
WordEmbeddingMixins
Extends:
This WordEmbeddingMixins class is provide methods for transforn sentences, tokens to vectors
Method Summary
Public Methods | ||
public |
async sentenceEncode(tokens: Array ): Tensor return the vectors of tokenized sentences This function require sentence to be tokenized via preprocessing |
|
public |
async transform(tokens: Array ): Tensor Transform tokenized sentences into tensor vectors |
|
public |
unknowVec(): Array return default replacement for unknown vec. |
Public Methods
public async sentenceEncode(tokens: Array ): Tensor source
return the vectors of tokenized sentences This function require sentence to be tokenized via preprocessing
Params:
Name | Type | Attribute | Description |
tokens | Array | array of string tokens of sentence |
Return:
Tensor | encoded sentences |
public async transform(tokens: Array ): Tensor source
Transform tokenized sentences into tensor vectors
Params:
Name | Type | Attribute | Description |
tokens | Array | 2d array for token of sentences |
Return:
Tensor | 2d tensor represent vectors of each input sentences |
Example:
let sentVec = await causalNetEmbedding.sentenceEncode([ ['this', 'is', 'test'] ]);
public unknowVec(): Array source
return default replacement for unknown vec. Currently it is set to zeros
Return:
Array | vec |