Socket
Book a DemoInstallSign in
Socket

js-rouge

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-rouge

Recall-Oriented Understudy for Gisting Evaluation (ROUGE) Evaluation Functions with TypeScript support

latest
Source
npmnpm
Version
3.1.5
Version published
Weekly downloads
51K
-1.38%
Maintainers
5
Weekly downloads
 
Created
Source

js-rouge

A JavaScript implementation of the Recall-Oriented Understudy for Gisting Evaluation (ROUGE) evaluation metric for summaries. This package implements the following metrics:

  • n-gram (ROUGE-N)
  • Longest Common Subsequence (ROUGE-L)
  • Skip Bigram (ROUGE-S)

Note: This is a fork of the original ROUGE.js by kenlimmj. This fork adds TypeScript types and other improvements.

Rationale

ROUGE is somewhat a standard metric for evaluating the performance of auto-summarization algorithms. However, with the exception of MEAD (which is written in Perl. Yes. Perl.), requesting a copy of ROUGE to work with requires one to navigate a barely functional webpage, fill up forms, and sign a legal release somewhere along the way while at it. These definitely exist for good reason, but it gets irritating when all one wishes to do is benchmark an algorithm.

Nevertheless, the paper describing ROUGE is available for public consumption. The appropriate course of action is then to convert the equations in the paper to a more user-friendly format, which takes the form of the present repository. So there. No more forms. See how life could have been made a lot easier for everyone if we were all willing to stop writing legalese or making people click submit buttons?

Quick Start

This package is available on NPM:

npm install js-rouge

To use it:

import { n, l, s } from 'js-rouge'; // ES Modules

// OR

const { n, l, s } = require('js-rouge'); // CommonJS

To run tests:

npm test

Usage

js-rouge provides three main functions:

  • ROUGE-N: n(candidate, reference, opts)
  • ROUGE-L: l(candidate, reference, opts)
  • ROUGE-S: s(candidate, reference, opts)

All functions take a candidate string, a reference string, and an optional configuration object.

ROUGE-L Example

import { l as rougeL } from 'js-rouge';

const reference = 'police killed the gunman';
const candidate = 'police kill the gunman';

const score = rougeL(candidate, reference, { beta: 0.5 });

console.log('score:', score); // => 0.75

Jackknife Resampling

The package also exports utility functions, including jackknife resampling as described in the original paper:

import { n as rougeN, jackKnife } from 'js-rouge';

const reference = 'police killed the gunman';
const candidates = [
  'police kill the gunman',
  'the gunman kill police',
  'the gunman police killed',
];

// Standard evaluation taking the arithmetic mean
jackKnife(candidates, reference, rougeN);

// A function that returns the max value in an array
const distMax = (arr) => Math.max(...arr);

// Modified evaluation taking the distribution maximum
jackKnife(candidates, reference, rougeN, distMax);

TypeScript

This package is written in TypeScript and includes type definitions. All functions and utilities are fully typed.

Versioning

Development will be maintained under the Semantic Versioning guidelines as much as possible in order to ensure transparency and backwards compatibility.

Releases will be numbered with the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibility bumps the major (and resets the minor and patch)
  • New additions without breaking backward compatibility bump the minor (and resets the patch)
  • Bug fixes and miscellaneous changes bump the patch

For more information on SemVer, visit http://semver.org/.

Bug Tracking and Feature Requests

Have a bug or a feature request? Please open a new issue.

Contributing

Please submit all pull requests against the main branch. All code should pass ESLint validation and tests.

The amount of data available for writing tests is unfortunately woefully inadequate. We've tried to be as thorough as possible, but that eliminates neither the possibility of nor existence of errors. The gold standard is the DUC data-set, but that too is form-walled and legal-release-walled, which is infuriating. If you have data in the form of a candidate summary, reference(s), and a verified ROUGE score you do not mind sharing, we would love to add that to the test harness.

License

MIT

Keywords

ROUGE

FAQs

Package last updated on 17 Dec 2025

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