word2vec4node

0.1.1 • Public • Published

Word2Vec4Node

Google Word2Vec Interface for Node.js with N-API

npm npm

Notice

Only Unix-like OS can use Word2Vec.train() method. pthread only working on POSIX, Windows can not use the method.

ChangeLog

See CHANGELOG

Installation

  • Install with npm:
npm install word2vec4node --save
  • Clone the repo:
git clone https://github.com/Astro36/word2vec4node.git

Usage

Example

Find the top-N most similar words:

const Word2Vec = require('word2vec4node');
const model = Word2Vec.load('./data/vectors.json');
// [서울] - [한국] + [일본]
console.log(model.analogy({ positive: ['서울', '일본'], negative: ['한국'] }, 5));

Which word from the words doesn’t match with the others:

const Word2Vec = require('word2vec4node');
const model = Word2Vec.load('./data/vectors.json');
console.log(model.findDifference(['', '여름', '가을', '얼음']));

Compute cosine distances from the words:

const Word2Vec = require('word2vec4node');
const model = Word2Vec.load('./data/vectors.json');
console.log(model.getVector('대한민국').distance(model.getVector('한국')));

License

Word2Vec4Node
Copyright (C) 2018  Astro
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.
 
You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

/word2vec4node/

    Package Sidebar

    Install

    npm i word2vec4node

    Weekly Downloads

    2

    Version

    0.1.1

    License

    LGPL-3.0

    Unpacked Size

    51.6 kB

    Total Files

    11

    Last publish

    Collaborators

    • astro36