similar-substring
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

SimilarSubstring

SimilarSubstring is a library that helps you to search for the most similar pattern from the text/paragraph you provided.

Algorithm used

This library is implemented based on Evolutionary Distance algorithm written by Sellers, Peter H. It is similar to Levenshtein Distance algorithm, but it is optimized for searching a similar part of the sequence.

Features

  • Search for the most similar part of the string by the given pattern
  • Return all of the parts if there is more than one most part which is scored the highest mark in terms of similarity

Installation

Install using NPM

npm install similar-substring --save

Import to your code

import { similarSubstring } from 'similar-substring';

Example

Usage

import { similarSubstring } from 'similar-substring';

// Your code here
const result = similarSubstring("I am coding", "mod");

Output

{
  similarity: 0.6666666666666666,
  items: [
    { substring: 'od', range: { startIndex: 6, endIndex: 7 } },
    { substring: 'cod', range: { startIndex: 5, endIndex: 7 } }
  ]
}

Readme

Keywords

none

Package Sidebar

Install

npm i similar-substring

Weekly Downloads

0

Version

1.0.4

License

ISC

Unpacked Size

15.6 kB

Total Files

9

Last publish

Collaborators

  • tszkitlai6