UNPKG

word2vector-json-ts

Version:

TypeScript library for processing Word2Vec output vectors in JSON format.

9 lines 293 B
export function getNormalize(a) { const magnitude = a.magnitude(); const vector = a.getDimensions(); if (magnitude === 0) { throw new Error('Cannot normalize a zero vector.'); } return vector.map((val) => val / magnitude); } //# sourceMappingURL=getNormalize.js.map