Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
how-similar
Advanced tools
Readme
This module compares two strings and returns a value on how similar they are from 0 - 1 (using a normalized levenshtein distance). The most basic use is:
> const {similarity} = require('how-similar')
> similarity('Dublin', 'Doblin')
0.833
The module can also compare a string to an array of strings to find which one is the most similar one:
> similarity('Dublin', ['Doblin', 'Devlin', 'Duuublin', 'Dublin'])
[ { key: 'Dublin', value: 1 },
{ key: 'Doblin', value: 0.875 },
{ key: 'Devlin', value: 0.75 },
{ key: 'Duuublin', value: 0.75 } ]
You can install with [npm]:
$ npm install --save how-similar
The module provides functions to deal with string / string comparison and string / array comparison. Still the easiest way to use it is to import similarity
:
> const {similarity} = require('how-similar')
Then as shown above you can pass two strings or an string and an array of strings. You can also pass a third parameter with options (it will be explained next).
The following use cases can be solved with the module:
> similarity('Dublin', 'Doblin')
0.833
> similarity('Dublin', ['Doblin', 'Devlin', 'Duuublin', 'Dublin'])
[ { key: 'Dublin', value: 1 },
{ key: 'Doblin', value: 0.875 },
...
{ignorecase: true}
):> similarity('Dublin', 'dUblIn', {ignorecase: true})
1
{stem: true}
):> similarity('This is Dublin', 'Thi is Dublin', {stem: true})
1
{except: [word1, word2, ...]}
)> similarity('This is Dublin in Ireland', 'This is Dublin', {except: ['in', 'Ireland']})
1
Copyright © 2019, Juan Convers. Released under the MIT License.
FAQs
Module to compare similarity between strings / arrays.
The npm package how-similar receives a total of 0 weekly downloads. As such, how-similar popularity was classified as not popular.
We found that how-similar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.