DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • While Performing Dependency Selection, I Avoid the Loss Of Sleep From Node.js Libraries' Dangers
  • Why You Don’t Need That New JavaScript Library
  • Deno vs. Node.js: The Showdown Nobody Asked For But Everyone Needed
  • Building a Tic-Tac-Toe Game Using React

Trending

  • AI, ML, and Data Science: Shaping the Future of Automation
  • Java Virtual Threads and Scaling
  • A Complete Guide to Modern AI Developer Tools
  • How the Go Runtime Preempts Goroutines for Efficient Concurrency
  1. DZone
  2. Coding
  3. JavaScript
  4. NLP Libraries for Node.js and JavaScript

NLP Libraries for Node.js and JavaScript

In this post, we will talk about the best NLP libraries for Node.js and JavaScript that we have come across.

By 
Devashish Mamgain user avatar
Devashish Mamgain
·
Oct. 14, 20 · Analysis
Likes (6)
Comment
Save
Tweet
Share
10.9K Views

Join the DZone community and get the full member experience.

Join For Free

What Is Natural Language Processing (NLP)?

Natural language refers to the way humans communicate with each other.

Natural Language Processing (NLP) is broadly defined as the electronic manipulation of natural language, like speech and text, by software.

NLP is important because we want to open up communication between machines and humans in a more natural way. NLP has various use cases such as running a search engine, sentimental analysis, entity-recognition, voice-based apps, chatbots, and personal assistants.

The history of natural language processing (NLP) generally started in the 1950s. Alan Turing published the article “Computing Machinery and Intelligence,” a pioneer seminal paper on artificial intelligence.

The introduction to Turing’s paper

Some of the notably successful NLP systems developed in the 1960s were SHRDLU and ELIZA. Up to the 1980s, most natural language processing systems were based on complex sets of hand-written rules. In the 1980s, the NLP started to pick up after the introduction of machine learning algorithms.

Now, decades later, the world is full of multiple NLP libraries and engines. Let’s look at some of them, especially for the newer languages, such as Node.js and JavaScript.

NLP Libraries for Node.js and JavaScript

Though there are many useful NLP libraries available such as Spacy, NLTK, and CoreNLP. However, most of these libraries are not available in JavaScript. We had a hard time finding some good NLP libraries in JavaScript. After a lot of research and testing, the following are the libraries we found to be useful:

#1 NLP.js

GitHub: https://github.com/axa-group/nlp.js

NLP.js is developed by the AXA group. It is an NLP library for building bots, with entity extraction, sentiment analysis, automatic language identify, and so more, supports 40 languages.

NLP.js is a perfect node.js library for building chatbots. Documentation is very clear, and usage is very easy.

Here is a basic code snippet to help you understand how easy it is to set it up.

Java
 




x
18


 
1
const { NlpManager } = require('node-nlp');
2
const manager = new NlpManager({ languages: ['en'] });
3

          
4
// Adds the utterances and intents for the NLP
5
manager.addDocument('en', 'goodbye for now', 'greetings.bye');
6
manager.addDocument('en', 'bye bye take care', 'greetings.bye');
7

          
8
// Train also the NLG
9
manager.addAnswer('en', 'greetings.bye', 'Till next time');
10
manager.addAnswer('en', 'greetings.bye', 'see you soon!');
11

          
12
// Train and save the model.
13
(async() => {
14
    await manager.train();
15
    manager.save();
16
    const response = await manager.process('en', 'I should go now');
17
    console.log(response);
18
})();



#2 Natural

GitHub: https://github.com/NaturalNode/natural

Natural is another famous NLP library for Node.js. “Natural” is a general natural language facility for Node.js. It currently supports tokenizing, stemming, classification, phonetics, tf-idf, WordNet, string similarity, and some inflections.

Java
 




xxxxxxxxxx
1


 
1
var natural = require('natural');
2
var tokenizer = new natural.WordTokenizer();
3
console.log(tokenizer.tokenize("your dog has fleas."));
4
// [ 'your', 'dog', 'has', 'fleas' ]
5

          
6
console.log(natural.HammingDistance("karolin", "kathrin", false));
7
console.log(natural.HammingDistance("karolin", "kerstin", false));
8
// If strings differ in length -1 is returned



#3 Compromise.cool

GitHub: https://github.com/spencermountain/compromise/

Compromise.cool is indeed a cool and lightweight library and very easy to use. It can be used to run NLP on your browser.

Please note that, Compromise works with the English language only.

Java
 




xxxxxxxxxx
1


 
1
let doc = nlp(entireNovel)
2

          
3
doc.if('the #Adjective of times').text()
4
// "it was the blurst of times??"
5
if (doc.has('simon says #Verb')) {
6
  return true
7
}



#4 Wink.js

GitHub: https://github.com/winkjs/wink-nlp-utils

Wink provides NLP functions for amplifying negations, managing elisions, creating ngrams, stems, phonetic codes to tokens, and more.

Java
 




xxxxxxxxxx
1
20


 
1
// Load wink-nlp-utils
2
var nlp = require( 'wink-nlp-utils' );
3

          
4
// Extract person's name from a string:
5
var name = nlp.string.extractPersonsName( 'Dr. Sarah Connor M. Tech., PhD. - AI' );
6
console.log( name );
7

          
8
// Tokenize a sentence.
9
var s = 'For details on wink, check out http://winkjs.org/ URL!';
10
console.log( nlp.string.tokenize( s, true ) );
11
// -> [ { value: 'For', tag: 'word' },
12
//      { value: 'details', tag: 'word' },
13
//      { value: 'on', tag: 'word' },
14
//      { value: 'wink', tag: 'word' },
15
//      { value: ',', tag: 'punctuation' },
16
//      { value: 'check', tag: 'word' },
17
//      { value: 'out', tag: 'word' },
18
//      { value: 'http://winkjs.org/', tag: 'url' },
19
//      { value: 'URL', tag: 'word' },
20
//      { value: '!', tag: 'punctuation' } ]



Conclusion

Choosing a library depends finally on the use case and the tech stack you are using. We narrowed down to NLP.js for using in Kommunicate chatbot. If you are looking for an NLP library for building chatbots, then I would recommend NLP.js. 

References: https://machinelearningmastery.com/natural-language-processing/

NLP Library Node.js JavaScript

Published at DZone with permission of Devashish Mamgain. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • While Performing Dependency Selection, I Avoid the Loss Of Sleep From Node.js Libraries' Dangers
  • Why You Don’t Need That New JavaScript Library
  • Deno vs. Node.js: The Showdown Nobody Asked For But Everyone Needed
  • Building a Tic-Tac-Toe Game Using React

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!