# text-sound-similarity-improved

> Library used to find degrees of similarity between text's phonetics. Uses double-methaphone and accounts for numbers.

Latest version **1.0.7** (published 2018-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install text-sound-similarity-improved
pnpm add text-sound-similarity-improved
yarn add text-sound-similarity-improved
bun add text-sound-similarity-improved
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2018-07-04 |
| First published | 2018-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 40.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Eduardo de la Garza Guerra |
| Maintainers | edlgg |
| Keywords | text, sound, similarity, improved, audio, phonetics, double, metaphone, numbers |

## Links

- npm: https://www.npmjs.com/package/text-sound-similarity-improved
- Repository: https://github.com/edlgg/text-sound-similarity-improved
- Homepage: https://github.com/edlgg/text-sound-similarity-improved#readme
- Issues: https://github.com/edlgg/text-sound-similarity-improved/issues
- npm.io page: https://npm.io/package/text-sound-similarity-improved

## Dependencies (2)

- [double-metaphone](https://npm.io/package/double-metaphone.md) ^1.0.2
- [string-similarity](https://npm.io/package/string-similarity.md) ^1.2.0

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2018-07-04
- 1.0.6 — 2018-07-04
- 1.0.4 — 2018-07-04
- 1.0.3 — 2018-07-04
- 1.0.1 — 2018-07-02
- 1.0.0 — 2018-07-02

## README

# Text sound similarity Improved

I tried using the text-sound-similarity package but it didnt take numbers into account. Also, it used Metaphone 1 and I thought it would be an improvement to use Metaphone 2. Both packages are very similar.

Finds degree of similarity between text's phonetics, based on [Metaphone 2](https://en.wikipedia.org/wiki/Metaphone#Double_Metaphone) and [Dice's Coefficient]. (https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient) algorithms. It also accounts for numbers.

Most of the code was based of this [package](https://www.npmjs.com/package/text-sound-similarity/v/1.0.2) which didnt fit my needs because I needed numbers.

## Install

```
npm install text-sound-similarity-improved
```

## Usage

```javascript
import { compareTwoTexts } from "text-sound-similarity-improved";

compareTwoTexts("lost", "loose"); // 0.6666666666666666
```

## API

Requiring the module gives an object with two methods:

### compareTwoTexts(text1, text2)

Returns a fraction between 0 and 1, which indicates the degree of similarity between phonemes of the two texts. 0 indicates completely different texts, 1 indicates identical texts

##### Arguments

1.  `text1 (string)`: The first text
2.  `text2 (string)`: The second text

Order does not make a difference.

##### Returns

`(number)`: A fraction from 0 to 1, both inclusive. Higher number indicates more similarity.

##### Examples

```javascript
import { compareTwoTexts } from "text-sound-similarity-improved";

compareTwoTexts("My name is Laura", "Her name is laura"); //0.7272727272727273
```

### findBestMatch(mainTexts, targetTexts)

Compares each string in `mainTexts` against each string in `targetTexts` and returns the most similar pair.

##### Arguments

1.  `mainTexts (Array<string>)`: The string list to match each target string against.
2.  `targetTexts (Array<string>)`: Each string in this array will be matched against each string in `mainTexts`.

##### Returns

`(Object)`: An object with the following properties:

-   `text`: Best match main string
-   `target`: Best match target string
-   `rating`: Similarity rating of them

##### Examples

```javascript
import { findBestMatch } from "text-sound-similarity-improved";

findBestMatch(["ponnie 4", "pawn e5"], ["pawn e4", "pawn e5", "e4"]);

/*
  Returns:
  {
      text: 'pawn e5',
      target: 'pawn e5',
      rating: 1
    }
*/
```

---
_Source: https://npm.io/package/text-sound-similarity-improved · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
