1.0.4 • Published 5 years ago

word-encoder-nlp v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Node.js - Word Encoder NLP

It's a basic word encoder.
Useful when working on projects, which need encoded words dictionary for Natural Language Processing (NLP).
Includes a JSON with preencoded words (source: https://storage.googleapis.com/tensorflow/tf-keras-datasets/imdb_word_index.json).
You can use it for your own sentiment classification or text classification.

Installation

Using npm:

npm install word-encoder-nlp

Usage

Import package:

const WordEncoder = require('word-encoder-nlp');

Then get the integer for your encoded word:

const word = 'google';
const encodedWord = WordEncoder.getEncoding(word);

If the word is not encoded yet, then the module will encode itself and saves it in the local dictionary.json file. Next time when you need the encoding of that word it will already exist.

Features

This module contains the following features:

  • Get size of your dictionary
const dictionarySize = WordEncoder.getSize();
  • Listing all available encodings
const dictionary = WordEncoder.getEncodings();
  • Get encoding for a single word
const encodedWord = WordEncoder.getEncoding('word'); // returns 88649
  • Encode an array of words
const wordsToEncode = ['Hi', '!', 'I', 'can', 'encode', 'every', 'word', '.'];

const encodingList = WordEncoder.encodeWords(wordsToEncode);
//[88643, 88644, 88645, 88646, 88647, 88648, 88649, 88650]

const encodingList = WordEncoder.encodeWords(wordsToEncode, true);
//[{"Hi":88643},{"!":88644},{"I":88645},{"can":88646},{"encode":88647},{"every":88648},{"word":88649},{".":88650}]

License

This project is licensed under the MIT License - see the LICENSE.md file for details.
License: MIT

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago