cos-similarity
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -9,3 +9,3 @@ 'use strict'; | ||
*/ | ||
function index(vectorA = [], vectorB = []) { | ||
function index (vectorA = [], vectorB = []) { | ||
const dimensionality = Math.min(vectorA.length, vectorB.length); | ||
@@ -12,0 +12,0 @@ let dotAB = 0; |
@@ -7,3 +7,3 @@ /** | ||
*/ | ||
export default function(vectorA = [], vectorB = []) { | ||
export default function (vectorA = [], vectorB = []) { | ||
const dimensionality = Math.min(vectorA.length, vectorB.length); | ||
@@ -10,0 +10,0 @@ let dotAB = 0; |
{ | ||
"name": "cos-similarity", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Computes the cosine similarity between two vectors", | ||
@@ -31,8 +31,7 @@ "keywords": [ | ||
"scripts": { | ||
"bench": "node -r esm bench.js", | ||
"bench": "node bench.js", | ||
"build": "rollup -i index.js -o dist/index.js -f cjs", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"lint": "eslint .", | ||
"prepare": "npm run build", | ||
"test": "nyc --reporter html tape -r esm index.test.js | faucet && nyc check-coverage --statements 100 --branches 100 --functions 100 --lines 100", | ||
"test": "nyc --reporter html tape -r esm index.test.js && nyc check-coverage --statements 100 --branches 100 --functions 100 --lines 100", | ||
"posttest": "npm run lint" | ||
@@ -44,14 +43,12 @@ }, | ||
"cosine-similarity": "1.0.1", | ||
"coveralls": "3.0.3", | ||
"doc-similarity": "0.0.1", | ||
"eslint": "5.16.0", | ||
"eslint-config-pretty-strict": "2.0.0", | ||
"eslint-plugin-prettier": "3.0.1", | ||
"esm": "3.2.22", | ||
"faucet": "0.0.1", | ||
"husky": "2.1.0", | ||
"nyc": "14.0.0", | ||
"prettier": "1.17.0", | ||
"rollup": "1.10.1", | ||
"tape": "4.10.1" | ||
"eslint": "7.0.0", | ||
"eslint-config-pretty-strict": "6.0.0", | ||
"eslint-plugin-prettier": "3.1.3", | ||
"esm": "3.2.25", | ||
"husky": "4.2.5", | ||
"nyc": "15.0.1", | ||
"prettier": "2.0.5", | ||
"rollup": "2.10.0", | ||
"tape": "5.0.0" | ||
}, | ||
@@ -58,0 +55,0 @@ "eslintConfig": { |
# cos-similarity | ||
[![npm version](https://img.shields.io/npm/v/cos-similarity.svg?style=flat-square)](https://www.npmjs.com/package/cos-similarity) | ||
[![Build Status](https://travis-ci.com/rtomrud/cos-similarity.svg?branch=master)](https://travis-ci.com/rtomrud/cos-similarity) | ||
[![Coverage Status](https://coveralls.io/repos/github/rtomrud/cos-similarity/badge.svg?branch=master)](https://coveralls.io/github/rtomrud/cos-similarity?branch=master) | ||
[![Code size](https://badgen.net/bundlephobia/minzip/cos-similarity)](https://bundlephobia.com/result?p=cos-similarity) | ||
[![build status](https://github.com/rtomrud/cos-similarity/workflows/build/badge.svg)](https://github.com/rtomrud/cos-similarity/actions?query=branch%3Amaster+workflow%3Abuild) | ||
[![npm version](https://badgen.net/npm/v/cos-similarity)](https://www.npmjs.com/package/cos-similarity) | ||
[![bundle size](https://badgen.net/bundlephobia/minzip/cos-similarity)](https://bundlephobia.com/result?p=cos-similarity) | ||
Computes the [cosine similarity](https://en.wikipedia.org/wiki/Cosine_similarity) between two vectors | ||
- Accepts vectors with different lengths, ignoring the additional dimensions of the longest one | ||
- Accepts zero vectors, returning `0` if any vector is `0`, `undefined` or `[]` | ||
## Installing | ||
@@ -34,24 +30,4 @@ | ||
## Benchmark | ||
```bash | ||
cosine-similarity x 56,881 ops/sec ±0.25% (97 runs sampled) | ||
compute-cosine-similarity x 1,036,728 ops/sec ±0.12% (98 runs sampled) | ||
doc-similarity cosineSim x 7,230,600 ops/sec ±0.86% (94 runs sampled) | ||
cos-similarity x 7,317,571 ops/sec ±0.73% (95 runs sampled) | ||
Fastest is cos-similarity | ||
``` | ||
To run the benchmark: | ||
```bash | ||
git clone https://github.com/rtomrud/cos-similarity.git | ||
cd cos-similarity | ||
npm install | ||
npm run bench | ||
``` | ||
## License | ||
[MIT](./LICENSE) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13
5466
33