:robot: Natural language processing with JavaScript

Overview

classifier.js

Open Source Love version PRs Welcome CD

🤖 An library for natural language processing with JavaScript

Table of Contents

Instalation

npm i classifier.js
# or
yarn add classifier.js

Example of use

import { Classifier } from 'classifier.js'

const classifier = new Classifier({ percentualReturn: true })

classifier.learn('I like cats', ['animal'])
classifier.learn('Cats are cool', ['animal'])
classifier.learn('Dogs are noisy', ['animal'])
classifier.learn('I love animals', ['animal'])
classifier.learn('I like my horse', ['animal'])
classifier.learn('Chocolate is good', ['food'])
classifier.learn('I eat apple', ['food'])
classifier.learn('Juice is very good', ['food'])
classifier.learn('Brazilians eat rice and beans', ['food'])
classifier.learn('Bananas are good for health', ['food'])

classifier.classify('Apple juice is awesome')
// OUTPUT: { unknown: '20%', animal: '0%', food: '80%' }

Auto detection of numeric strings shape

import { Classifier } from 'classifier.js'

const classifier = new Classifier({ percentualReturn: true })

classifier.learn('000.000.000-11', ['cpf'])
classifier.learn('00.000.000/0001-00', ['cnpj'])
classifier.learn('00155-333', ['zipcode'])

classifier.classify('999.999.999-99')
// OUTPUT: { unknown: '0%', cpf: '100%', cnpj: '0%', zipcode: '0%' }
classifier.classify('99.999.999/9999-99')
// OUTPUT: { unknown: '0%', cpf: '0%', cnpj: '100%', zipcode: '0%' }
classifier.classify('99999-999')
// OUTPUT: { unknown: '0%', cpf: '0%', cnpj: '0%', zipcode: '100%' }

API

learn

Receive data with an array of related categories.

classifier.learn('Your sentence', ['your-category'])

classify

Classify a sentence based on received data.

classifier.classify('Sentence to classify')

resetKnowledge

Removes all that was learned.

classifier.resetKnowledge()

toJSON

Saves classifier data to a JSON file that can be imported later.

classifier.toJSON('myFolder/savedClassifier.json')
# Or simply
classifier.toJSON('savedClassifier.json')

fromJSON

Imports data from a JSON file.

classifier.fromJSON('myFolder/savedClassifier.json')
# Or simply
classifier.fromJSON('savedClassifier.json')

toYAML

Saves classifier data to an YAML file that can be imported later.

classifier.toJSON('myFolder/savedClassifier.json')
# Or simply
classifier.toJSON('savedClassifier.json')

fromYAML

Imports data from an YAML file.

classifier.fromJSON('myFolder/savedClassifier.yaml')
# Or simply
classifier.fromJSON('savedClassifier.yaml')
You might also like...

Differential Programming in JavaScript.

April 19, 2018 TensorFlow.js was recently released. It is well engineered, provides an autograd-style interface to backprop, and has committed to supp

Dec 29, 2022

Machine learning tools in JavaScript

ml.js - Machine learning tools in JavaScript Introduction This library is a compilation of the tools developed in the mljs organization. It is mainly

Jan 1, 2023

Deep Neural Network Sandbox for JavaScript.

Deep Neural Network Sandbox for JavaScript.

Deep Neural Network Sandbox for Javascript Train a neural network with your data & save it's trained state! Demo • Installation • Getting started • Do

Jan 4, 2023

A WebGL accelerated JavaScript library for training and deploying ML models.

TensorFlow.js TensorFlow.js is an open-source hardware-accelerated JavaScript library for training and deploying machine learning models. ⚠️ We recent

Jan 4, 2023

JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js

JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js

face-api.js JavaScript face recognition API for the browser and nodejs implemented on top of tensorflow.js core (tensorflow/tfjs-core) Click me for Li

Jan 2, 2023

Call Python packages in JavaScript.

Call Python packages in JavaScript.

Introduction to Boa Boa is the Python Bridge Layer in Pipcook, it lets you call Python functions seamlessly in Node.js, it delivers any Python module

Jan 5, 2023

Linear Regression library in pure Javascript

Lyric Linear Regression library in pure Javascript Lyric can help you analyze any set of x,y series data by building a model that can be used to: Crea

Dec 22, 2020

JavaScript Machine Learning Toolkit

The JavaScript Machine Learning Toolkit, or JSMLT, is an open source JavaScript library for education in machine learning.

Nov 23, 2022

K-nearest neighbors algorithm for supervised learning implemented in javascript

kNear Install npm install knear --save About kNear is a javascript implementation of the k-nearest neighbors algorithm. It is a supervised machine lea

Mar 7, 2022
Comments
  • Add storage options

    Add storage options

    🗒️ Context

    When you train the classifier, by default, all knowledge will be storage in memory, we are creating new saving option to not loose learned data after program execution.

    Options

    • [x] JSON
    • [x] YAML
    • [ ] Redis (Check need)
    enhancement 
    opened by NathanFirmo 1
  • RFC: text analisis

    RFC: text analisis

    📓 Context

    Google has a Natural Language API that can analize tokens and entiites inside a text. I think we could have something like this in classifier.js, even it was more simple... I would like to know your opinion about this :smile:

    Example of classification by Google API

    image

    RFC 
    opened by NathanFirmo 0
  • Add new classification algorithms

    Add new classification algorithms

    :spiral_notepad: Context

    Now the classifier has only one classification method. In the future, it would have more algorithms for diferents scenarios. It also would be able to automatically choose best algoritm for a type of dataset, considerating accuracy and computational complexity.

    enhancement 
    opened by NathanFirmo 0
  • Method calculate accuracy

    Method calculate accuracy

    🗒️ Context

    Add a method to calculate algorithm accuracy based on a datase.

    Example

    [
      {
        "sentence": "im feeling quite sad and sorry for myself but ill snap out of it soon",
        "category": "sadness"
      },
      {
        "sentence": "i feel like i am still looking at a blank canvas blank pieces of paper",
        "category": "sadness"
      },
      {
        "sentence": "i feel like a faithful servant",
        "category": "love"
      },
      {
        "sentence": "i am just feeling cranky and blue",
        "category": "anger"
      },
      {
        "sentence": "i can have for a treat or if i am feeling festive",
        "category": "joy"
      },
      {
        "sentence": "i start to feel more appreciative of what god has done for me",
        "category": "joy"
      },
    ]
    

    Behaviour

    The classifier will automatically split dataset into train and validation data and will calculate its own accuracy.

    enhancement 
    opened by NathanFirmo 0
Owner
Nathan Firmo
Just a software engineer student that loves Linux and NeoVim.
Nathan Firmo
general natural language facilities for node

natural "Natural" is a general natural language facility for nodejs. It offers a broad range of functionalities for natural language processing. Docum

null 10k Jan 9, 2023
Retext is a natural language processor powered by plugins part of the unified collective.

retext is a natural language processor powered by plugins part of the unified collective. Intro retext is an ecosystem of plugins for processing natur

retext 2.2k Dec 29, 2022
the 'natural satellite' subnet manager

deimos the 'natural satellite' subnet manager more just built against a grudge, because a spreadsheet is the worst way to store this kind of informati

Aaron Duce 2 Feb 7, 2022
An NLP library for building bots, with entity extraction, sentiment analysis, automatic language identify, and so more

NLP.js If you're looking for the version 3 docs, you can find them here Version 3 "NLP.js" is a general natural language utility for nodejs. Currently

AXA 5.3k Dec 29, 2022
Deep Learning in Javascript. Train Convolutional Neural Networks (or ordinary ones) in your browser.

ConvNetJS ConvNetJS is a Javascript implementation of Neural networks, together with nice browser-based demos. It currently supports: Common Neural Ne

Andrej 10.4k Dec 31, 2022
[UNMAINTAINED] Simple feed-forward neural network in JavaScript

This project has reached the end of its development as a simple neural network library. Feel free to browse the code, but please use other JavaScript

Heather 8k Dec 26, 2022
A neural network library built in JavaScript

A flexible neural network library for Node.js and the browser. Check out a live demo of a movie recommendation engine built with Mind. Features Vector

Steven Miller 1.5k Dec 31, 2022
Pure Javascript OCR for more than 100 Languages 📖🎉🖥

Version 2 is now available and under development in the master branch, read a story about v2: Why I refactor tesseract.js v2? Check the support/1.x br

Project Naptha 29.2k Dec 31, 2022
WebGL-accelerated ML // linear algebra // automatic differentiation for JavaScript.

This repository has been archived in favor of tensorflow/tfjs. This repo will remain around for some time to keep history but all future PRs should be

null 8.5k Dec 31, 2022
A JavaScript deep learning and reinforcement learning library.

neurojs is a JavaScript framework for deep learning in the browser. It mainly focuses on reinforcement learning, but can be used for any neural networ

Jan 4.4k Jan 4, 2023