Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

natural

Package Overview
Dependencies
Maintainers
3
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

natural

General natural language (tokenizing, stemming (English, Russian, Spanish), part-of-speech tagging, sentiment analysis, classification, inflection, phonetics, tfidf, WordNet, jaro-winkler, Levenshtein distance, Dice's Coefficient) facilities for node.

  • 8.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
182K
increased by0.38%
Maintainers
3
Weekly downloads
 
Created

What is natural?

The 'natural' npm package is a general natural language processing (NLP) library for Node.js. It provides a variety of tools and algorithms for text processing, including tokenization, stemming, classification, and more.

What are natural's main functionalities?

Tokenization

Tokenization is the process of breaking down text into individual words or tokens. The 'natural' package provides several tokenizers, including word and sentence tokenizers.

const natural = require('natural');
const tokenizer = new natural.WordTokenizer();
console.log(tokenizer.tokenize('This is a sample sentence.'));

Stemming

Stemming reduces words to their root form. The 'natural' package includes several stemmers, such as the Porter Stemmer, which is used in this example.

const natural = require('natural');
const stemmer = natural.PorterStemmer;
console.log(stemmer.stem('running'));

Classification

Classification involves categorizing text into predefined classes. The 'natural' package supports several classifiers, including the Naive Bayes classifier demonstrated here.

const natural = require('natural');
const classifier = new natural.BayesClassifier();
classifier.addDocument('I love programming.', 'positive');
classifier.addDocument('I hate bugs.', 'negative');
classifier.train();
console.log(classifier.classify('I love bugs.'));

Phonetic Matching

Phonetic matching is used to find words that sound similar. The 'natural' package includes algorithms like SoundEx for this purpose.

const natural = require('natural');
const soundEx = natural.SoundEx;
console.log(soundEx.compare('phonetic', 'fonetic'));

String Distance

String distance measures how similar two strings are. The 'natural' package provides several distance algorithms, including Jaro-Winkler distance.

const natural = require('natural');
const distance = natural.JaroWinklerDistance;
console.log(distance('dixon', 'dicksonx'));

Other packages similar to natural

Keywords

FAQs

Package last updated on 09 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc