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

match_percentage

v1.0.5

Published

I originally wrote this to compare title headlines from local news websites I web scrape. On any given day, all the websites can have the same story with the title being very similar, which helps me check for duplicate articles.

Downloads

4

Readme

README

This is a simple Node.js module for calculating the match percentage between two sentences. It removes simple words (such as "of", "at", "i", etc.) from the sentences before calculating the match percentage.

I originally wrote this to compare title headlines from local news websites I web scrape. On any given day, all the websites can have the same story with the title being very similar, which helps me check for duplicate articles.

Get me at [email protected]

Open issues on github - contributions welcomed

Usage

To use the module, simply install it using npm or yarn:

npm install match_percentage

or

yarn add match_percentage

Once the module is installed, you can import it into your code and use the checkMatchPercentage(s1,s2) function to calculate the match percentage between two sentences. The function takes two arguments: the two sentences to compare. It returns an object with two properties:

  • matchPercentage: The match percentage between the two sentences, as a number between 0 and 100.
  • match: A string indicating whether the two sentences are likely to be a match, based on the match percentage.

Here is an example of how to use the module:

const matchPercentage = require('match_percentage');

or

import matchPercentage from "match_percentage";


const sentence1 = 'I am 83% sure that was a unicorn';

const sentence2 = 'I had 83% for maths and 68% for French';

const result = matchPercentage(sentence1, sentence2);

console.log(result);

Output:

{
  matchPercentage: 22,
  match: false
}
const sentence1 = 'This is a simple sentence.';

const sentence2 = 'This is a very similar sentence.';

output:

{
  matchPercentage: 68,
  match: true
}

IMO these are similar enough to be talking about the same thing. You can set the truth level!

truthLevel (default 60)

The default match level is 60, but you can adjust it as needed.

const matchLevel = 75; // Adjust the match level to your preference.

const result = matchPercentage(sentence1, sentence2, truthLevel);
console.log(result);

Simple Words (coming soon)

The module includes a list of simple words that are removed from the sentences before calculating the match percentage.

Here is an example of how to customize the list of simple words:

javascript const matchPercentage = require('match-percentage');

const customSimpleWords = ['very', 'simple'];

const matchLevel = 75;

const result = await matchPercentage(sentence1, sentence2, customSimpleWords, matchLevel);

console.log(result);

Conclusion

This module provides a simple way to calculate the match percentage between two sentences. It can be used in a variety of applications, such as plagiarism detection, text matching, and natural language processing.