npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

multilingual-sentiment-analysis

v1.0.0

Published

A high-performance multilingual sentiment analysis module for Node.js powered by Hugging Face Transformers.

Readme

Multilingual Sentiment Analysis

A high-performance multilingual sentiment analysis module for Node.js, leveraging state-of-the-art transformer models (via Hugging Face Transformers) to provide accurate sentiment predictions across multiple languages.

Features

  • Multilingual Support: Works out-of-the-box with English, Spanish, French, German, Italian, Portuguese, and more.
  • Transformer-based: Uses the distilbert-base-multilingual-cased-sentiments-student model for efficient and accurate inference.
  • Simple API: Provides an easy-to-use async interface for analyzing text.
  • Reliability Scoring: Includes a confidence score and a reliability flag for each prediction.
  • Lightweight Inference: Built with @huggingface/transformers for optimized execution in Node.js environments.

Installation

npm install

Usage

Basic Example

import { getAnalyzer } from 'multilingual-sentiment-analysis';

async function main() {
    const analyzer = getAnalyzer();
    
    // The first call might take a moment to load the model
    const result = await analyzer.analyze('This product is absolutely wonderful!');
    
    console.log(result);
    // { sentiment: 'positive', confidence: 0.99, isReliable: true }
}

main();

Multilingual Support

const esResult = await analyzer.analyze('¡Este producto es excelente!');
// { sentiment: 'positive', confidence: 0.98, isReliable: true }

const frResult = await analyzer.analyze('C\'est terrible, je déteste ça.');
// { sentiment: 'negative', confidence: 0.97, isReliable: true }

Advanced Usage (Custom Models)

You can instantiate the SentimentAnalyzer with a custom model from the Hugging Face Hub:

import { SentimentAnalyzer } from 'multilingual-sentiment-analysis';

const customAnalyzer = new SentimentAnalyzer('Xenova/bert-base-multilingual-uncased-sentiment');
await customAnalyzer.waitForReady();
const result = await customAnalyzer.analyze('I love this!');

API Reference

getAnalyzer(): SentimentAnalyzer

Returns a singleton instance of the default sentiment analyzer.

SentimentAnalyzer Class

  • constructor(modelName?: string): Create a new analyzer with an optional custom model.
  • analyze(text: string): Promise<SentimentResult>: Analyzes the sentiment of the input text.
  • waitForReady(): Promise<void>: Ensures the underlying transformer model is loaded and ready.

SentimentResult Object

  • sentiment: 'positive' | 'negative' | 'neutral'
  • confidence: number (0.0 to 1.0)
  • isReliable: boolean (True if confidence > 0.6)

Development Scripts

  • npm run build: Compile TypeScript to JavaScript.
  • npm run test: Run the test suite using Mocha.
  • npm run evaluate: Run an evaluation script with a battery of test cases across different languages.
  • npm run evaluate -- -i: Run evaluation in interactive mode for custom testing.
  • npm run lint: Run ESLint to ensure code quality.

License

ISC