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 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-rouge

v3.0.0

Published

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

Downloads

44,125

Readme

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, like so:

npm install --save js-rouge

To use it, simply require the package:

import rouge from 'js-rouge'; // ES2015+

// OR

const rouge = require('js-rouge'); // CommonJS

A small but growing number of tests exist. To run them:

npm test

This should give you many lines of colorful text in your CLI. Naturally, you'll need to have Mocha installed, but you knew that already.

NOTE: Function test coverage is 100%, but branch coverage numbers look horrible because the current testing implementation has no way of accounting for the additional code injected by Babel when transpiling from ES2015 to ES5. A fix is in the pipeline, but if anyone has anything good, feel free to PR!

Usage

Rouge.js provides three functions:

  • ROUGE-N: rouge.n(cand, ref, opts)
  • ROUGE-L: rouge.l(cand, ref, opts)
  • ROUGE-S: rouge.s(cand, ref, opts)

All functions take in a candidate string, a reference string, and a configuration object specifying additional options. Documentation for the options is provided inline in lib/rouge.js. Type signatures are specified and checked using TypeScript.

Here's an example evaluating ROUGE-L using an averaged-F1 score instead of the DUC-F1:

import { l as rougeL } from 'rouge';

const ref = 'police killed the gunman';
const cand = 'police kill the gunman';

rougeL(cand, ref, { beta: 0.5 });

In addition, the main functions rely on a battery of utility functions specified in lib/utils.js. These perform a bunch of things like quick evaluation of skip bigrams, string tokenization, sentence segmentation, and set intersections.

Here's an example applying jackknife resampling as described in the original paper:

import { n as rougeN } from 'rouge';
import { jackKnife } from 'rouge/utils';

const ref = 'police killed the gunman';
const cands = ['police kill the gunman', 'the gunman kill police', 'the gunman police killed'];

// Standard evaluation taking the arithmetic mean
jackKnife(cands, ref, rougeN);

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

// Modified evaluation taking the distribution maximum
jackKnife(cands, ref, rougeN, distMax);

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.

Before opening any issue, please search for existing issues and read the Issue Guidelines.

Contributing

Please submit all pull requests against *-wip branches. All code should pass ESLint validation. Note that files in /lib are written in TypeScript syntax and transpiled to corresponding files in /dist. Gulp build pipelines exist and should be used.

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