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

set-distance

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

set-distance

Finds measure of similarity/distance between two input sets.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
increased by109.09%
Maintainers
1
Weekly downloads
 
Created
Source

set-distance

Finds similarity/distance between two input sets.
Algorithms implemented:
1). Sorensen-Dice Coefficient.
2). Jaccard Index.
3). Ochiai Coefficient.
4). Overlap Coefficient.
5). Levenshtein/Edit Distance.

Installation

npm install set-distance --save
bower install set-distance --save

Usage

Javascript

var Distance = require('set-distance');
//SorensenDice Coefficient
var sc = new Distance.SorensenDice(['S', 'A', 'T', 'U', 'R', 'D', 'A', 'Y'], ['S', 'U', 'N', 'D', 'A', 'Y']).getCoefficient();
console.log(sc);
//Output: 0.7142857142857143

//Jaccard Index
var jc = new Distance.Jaccard(['S', 'A', 'T', 'U', 'R', 'D', 'A', 'Y'], ['S', 'U', 'N', 'D', 'A', 'Y']).getCoefficient();
console.log(jc);
//Output: 0.5555555555555556

//Ochiai Coefficient
var oc = new Distance.Ochiai(['S', 'A', 'T', 'U', 'R', 'D', 'A', 'Y'], ['S', 'U', 'N', 'D', 'A', 'Y']).getCoefficient();
console.log(oc);
//Output: 0.7216878364870323

//Overlap Coefficient
var ov = new Distance.Overlap(['S', 'A', 'T', 'U', 'R', 'D', 'A', 'Y'], ['S', 'U', 'N', 'D', 'A', 'Y']).getCoefficient();
console.log(ov);
//Output: 0.8333333333333334

//Levenshtein/Edit Distance
var ld = new Distance.Levenshtein(['S', 'A', 'T', 'U', 'R', 'D', 'A', 'Y'], ['S', 'U', 'N', 'D', 'A', 'Y']).getCoefficient();
console.log(ld);
//Output: 3

TypeScript

import * as Distance from 'set-distance';
//SorensenDice Coefficient
var sc = new Distance.SorensenDice(['S', 'A', 'T', 'U', 'R', 'D', 'A', 'Y'], ['S', 'U', 'N', 'D', 'A', 'Y']).getCoefficient();
console.log(sc);
//Output: 0.7142857142857143

//Jaccard Index
var jc = new Distance.Jaccard(['S', 'A', 'T', 'U', 'R', 'D', 'A', 'Y'], ['S', 'U', 'N', 'D', 'A', 'Y']).getCoefficient();
console.log(jc);
//Output: 0.5555555555555556

//Ochiai Coefficient
var oc = new Distance.Ochiai(['S', 'A', 'T', 'U', 'R', 'D', 'A', 'Y'], ['S', 'U', 'N', 'D', 'A', 'Y']).getCoefficient();
console.log(oc);
//Output: 0.7216878364870323

//Overlap Coefficient
var ov = new Distance.Overlap(['S', 'A', 'T', 'U', 'R', 'D', 'A', 'Y'], ['S', 'U', 'N', 'D', 'A', 'Y']).getCoefficient();
console.log(ov);
//Output: 0.8333333333333334

//Levenshtein/Edit Distance
var ld = new Distance.Levenshtein(['S', 'A', 'T', 'U', 'R', 'D', 'A', 'Y'], ['S', 'U', 'N', 'D', 'A', 'Y']).getCoefficient();
console.log(ld);
//Output: 3

Keywords

FAQs

Package last updated on 20 May 2019

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