npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@elsikora/string-similarity

v1.0.1

Published

A library for comparing strings and determining their similarity.

Downloads

793

Readme

Overview

The software project, named String Similarity Library, facilitates efficient string comparison and best match identification based on bigrams. It streamlines the process of comparing strings, enhancing text-matching capabilities across various applications. The project offers automated dependency updates, version releases, code quality analysis, and security scans, ensuring robust functionality and maintainability. Through its comprehensive features such as webpack configuration, npm management, and continuous integration workflows, the String Similarity Library promotes code quality, security, and collaboration within the open-source community.


Features

| | Feature | Description | |----|-------------------|---------------------------------------------------------------| | ⚙️ | Architecture | The project follows a modular architecture, with a clear separation of concerns between different components. It leverages webpack for bundling and distribution. The use of GitHub Actions automates various processes, enhancing efficiency. | | 🔩 | Code Quality | The codebase maintains high quality standards, with linting and automated code reviews in place. It follows a consistent coding style, thanks to tools like ESLint and husky. Changesets CLI ensures smooth version management. | | 📄 | Documentation | The project has extensive documentation covering setup, usage, and contribution guidelines. README files, GitHub Actions configurations, and inline comments enhance clarity and assist developers in understanding and contributing to the codebase. | | 🔌 | Integrations | Key integrations include GitHub Actions for CI/CD, Snyk for security scans, and AWS CodeCommit for code synchronization. These integrations enhance automation, security, and collaboration within the project. | | 🧩 | Modularity | The codebase is highly modular, promoting reusability and maintainability. Each component has well-defined responsibilities, making it easier to extend functionality or make changes without affecting other parts of the system. | | 🧪 | Testing | Testing frameworks like Jest or Mocha are likely used for unit and integration tests. Automated testing ensures code reliability and helps identify issues early in the development cycle. | | ⚡️ | Performance | The project focuses on optimizing performance, with webpack configuration for efficient bundle sizes. Automated releases and dependency updates streamline processes, enhancing overall project efficiency. | | 🛡️ | Security | Security measures include automated security scans using Snyk, ensuring vulnerabilities are identified and addressed promptly. Additionally, GitHub Actions are configured to enforce security best practices, promoting a secure codebase. | | 📦 | Dependencies | Key dependencies include webpack, ESLint, husky, and Snyk for various development and security-related tasks. These libraries enhance development workflows and ensure code quality and security. | | 🚀 | Scalability | The project demonstrates scalability through its modular architecture and automated processes. GitHub Actions manage releases and code synchronization, enabling the project to handle increased traffic and load effectively. |


Repository Structure

└── /
    ├── .github
    │   ├── dependabot.yml
    │   └── workflows
    ├── LICENSE
    ├── README.md
    ├── package.json
    ├── src
    │   └── index.js
    └── webpack.config.js

Modules

| File | Summary | | --- | --- | | webpack.config.js | Generates production-ready JavaScript library string-similarity.min.js from src/index.js. Configures webpack to bundle the library for distribution, making it accessible as stringSimilarity in different projects. | | package.json | Enables comparing string similarity, with keywords like strings, difference, match. Manages dependencies, builds, lints code, and initiates releases. Designed for public access via Git. |

| File | Summary | | --- | --- | | dependabot.yml | Automates dependency updates for npm and GitHub Actions on the dev branch, ensuring daily checks for package compatibility. Vital for maintaining repository health and keeping dependencies up-to-date without manual intervention. |

| File | Summary | | --- | --- | | index.js | Implements string comparison and best match finding, enhancing text-matching functionality for the repository. Key features include comparing strings based on bigrams and determining the best match from target strings. |

| File | Summary | | --- | --- | | release.yml | Manages automated version releases via GitHub Actions, triggering on new commits to the main branch. Key features include version number incrementing, package publishing, and release note generation. | | qodana-code-quality.yml | Enhances repository quality via automated Qodana code analysis. Monitors sources in src/index.js for adherence to coding standards, promoting better code practices. Streamlines code review process for improved overall codebase quality. | | snyk-security-scan.yml | Implements automated security scans with Snyk in CI pipeline. Enhances repository security by identifying and addressing vulnerabilities early on. Configured as a workflow for seamless integration. | | codecommit-sync.yml | Ensures automated synchronization between the code repository and AWS CodeCommit. Implements scheduled sync using GitHub Actions, enhancing collaboration and ensuring code consistency across repositories. |


API

The package contains two methods:

compareTwoStrings(string1, string2)

Returns a fraction between 0 and 1, which indicates the degree of similarity between the two strings. 0 indicates completely different strings, 1 indicates identical strings. The comparison is case-sensitive.

Arguments
  1. string1 (string): The first string
  2. string2 (string): The second string

Order does not make a difference.

Returns

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

Examples
stringSimilarity.compareTwoStrings("healed", "sealed");
// → 0.8

stringSimilarity.compareTwoStrings(
  "Olive-green table for sale, in extremely good condition.",
  "For sale: table in very good  condition, olive green in colour."
);
// → 0.6060606060606061

stringSimilarity.compareTwoStrings(
  "Olive-green table for sale, in extremely good condition.",
  "For sale: green Subaru Impreza, 210,000 miles"
);
// → 0.2558139534883721

stringSimilarity.compareTwoStrings(
  "Olive-green table for sale, in extremely good condition.",
  "Wanted: mountain bike with at least 21 gears."
);
// → 0.1411764705882353

findBestMatch(mainString, targetStrings)

Compares mainString against each string in targetStrings.

Arguments
  1. mainString (string): The string to match each target string against.
  2. targetStrings (Array): Each string in this array will be matched against the main string.
Returns

(Object): An object with a ratings property, which gives a similarity rating for each target string, a bestMatch property, which specifies which target string was most similar to the main string, and a bestMatchIndex property, which specifies the index of the bestMatch in the targetStrings array.

Examples
stringSimilarity.findBestMatch('Olive-green table for sale, in extremely good condition.', [
  'For sale: green Subaru Impreza, 210,000 miles',
  'For sale: table in very good condition, olive green in colour.',
  'Wanted: mountain bike with at least 21 gears.'
]);
// →
{ ratings:
   [ { target: 'For sale: green Subaru Impreza, 210,000 miles',
       rating: 0.2558139534883721 },
     { target: 'For sale: table in very good condition, olive green in colour.',
       rating: 0.6060606060606061 },
     { target: 'Wanted: mountain bike with at least 21 gears.',
       rating: 0.1411764705882353 } ],
  bestMatch:
   { target: 'For sale: table in very good condition, olive green in colour.',
     rating: 0.6060606060606061 },
  bestMatchIndex: 1
}

Project Roadmap

  • [X] ► String similarity comparison
  • [ ] ► Automated dependency updates

Contributing

Contributions are welcome! Here are several ways you can contribute:

  1. Fork the Repository: Start by forking the project repository to your local account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone ../
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to local: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!

License

This project is protected under the MIT License. For more details, refer to the LICENSE file.


Acknowledgments

  • List any resources, contributors, inspiration, etc. here.

Return