Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/efraespada/similarity-string
Node package for comparing common char sets
https://github.com/efraespada/similarity-string
Last synced: 10 days ago
JSON representation
Node package for comparing common char sets
- Host: GitHub
- URL: https://github.com/efraespada/similarity-string
- Owner: efraespada
- License: apache-2.0
- Created: 2018-11-16T14:07:32.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-17T16:49:32.000Z (about 6 years ago)
- Last Synced: 2024-12-11T16:50:45.113Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# similarity-string
[![npm version][npm-badge]][npm]
[![Build Status][travis-badge]][travis]
[![Dependency Status][david-badge]][david]
[![DevDependency Status][david-badge-dev]][david-dev]similarity-string compares strings **focusing on common char sets**.
```bash
npm install similarity-string --save
```
Implement it:
```node
String.similarity = require("similarity-string");
let percent = String.similarity("xummy", "dummy");
```
### Reason
I recently tested the Levenshtein distance for matching poblation names with a given value and I notice it wasn't enought.> The Levenshtein distance is a string metric for measuring the difference between two sequences ([Wikipedia](https://en.wikipedia.org/wiki/Levenshtein_distance))
Comparing a value with a set of names the Levenshtein distance returned the same distance for multiple names.
I got better results by comparing common char sequences:
```
xummy - dummy: 60.00% [░░░░░░░░░░░░░░░ ] (leven: 1)
dxmmy - dummy: 30.00% [░░░░░░░░ ] (leven: 1)
```
### Test
Clone the repository and run:
```bash
npm install
npm test
``````
xummy - dummy: 60.00% [░░░░░░░░░░░░░░░ ]
dxmmy - dummy: 30.00% [░░░░░░░░ ]
duxmy - dummy: 20.00% [░░░░░ ]
dumxy - dummy: 30.00% [░░░░░░░░ ]
dummx - dummy: 60.00% [░░░░░░░░░░░░░░░ ]
xumming - dumming: 71.43% [░░░░░░░░░░░░░░░░░░ ]
dxmming - dumming: 47.62% [░░░░░░░░░░░░ ]
duxming - dumming: 33.33% [░░░░░░░░ ]
dumxing - dumming: 28.57% [░░░░░░░ ]
dummxng - dumming: 33.33% [░░░░░░░░ ]
dummixg - dumming: 47.62% [░░░░░░░░░░░░ ]
dumminx - dumming: 71.43% [░░░░░░░░░░░░░░░░░░ ]
```
#### Levenshtein comparision
```
xummy - dummy: 80.00% [░░░░░░░░░░░░░░░░░░░░ ]
dxmmy - dummy: 80.00% [░░░░░░░░░░░░░░░░░░░░ ]
duxmy - dummy: 80.00% [░░░░░░░░░░░░░░░░░░░░ ]
dumxy - dummy: 80.00% [░░░░░░░░░░░░░░░░░░░░ ]
dummx - dummy: 80.00% [░░░░░░░░░░░░░░░░░░░░ ]
xumming - dumming: 85.71% [░░░░░░░░░░░░░░░░░░░░░ ]
dxmming - dumming: 85.71% [░░░░░░░░░░░░░░░░░░░░░ ]
duxming - dumming: 85.71% [░░░░░░░░░░░░░░░░░░░░░ ]
dumxing - dumming: 85.71% [░░░░░░░░░░░░░░░░░░░░░ ]
dummxng - dumming: 85.71% [░░░░░░░░░░░░░░░░░░░░░ ]
dummixg - dumming: 85.71% [░░░░░░░░░░░░░░░░░░░░░ ]
dumminx - dumming: 85.71% [░░░░░░░░░░░░░░░░░░░░░ ]
```[david]: https://david-dm.org/efraespada/similarity-string
[david-badge]: https://david-dm.org/efraespada/similarity-string.svg
[travis]: https://travis-ci.org/efraespada/similarity-string
[travis-badge]: https://travis-ci.org/efraespada/similarity-string.svg?branch=master
[david-dev]: https://david-dm.org/efraespada/similarity-string?type=dev
[david-badge-dev]: https://david-dm.org/efraespada/similarity-string/dev-status.svg
[npm]: https://www.npmjs.com/package/similarity-string
[npm-badge]: https://badge.fury.io/js/similarity-string.svg