GithubHelp home page GithubHelp logo

sshahzaiib / wagner_fischer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 7 KB

Implementation of the Wagner-Fischer algorithm in JavaScript for computing the Levenshtein distance between two strings, useful in applications like spell checking, DNA sequence alignment, and natural language processing.

License: MIT License

JavaScript 100.00%
spellcheck spellchecker spelling wagner-fischer-algorithm

wagner_fischer's Introduction

Wagner-Fischer Algorithm Implementation

This script implements the Wagner-Fischer algorithm to compute the Levenshtein distance between two strings. The Levenshtein distance is a measure of the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into the other.

Prerequisites

  • Node.js
  • zx

Installation

  1. Install Node.js from https://nodejs.org/.
  2. Install zx globally with npm:
npm install -g zx

Usage

  1. Make sure the script has execute permissions:
chmod +x wagner_fischer.mjs
  1. Run the script with a word as an argument:
./wagner_fischer.mjs

The script will download a dictionary file (words.txt) if it does not exist in the current directory. It will then load the dictionary and compute the Levenshtein distance between the provided word and each word in the dictionary.

Functions

  • loadDictionary(): Loads a dictionary from a text file. Each line in the file should contain one word. The function returns an array of words.

  • wagnerFischer(s1, s2): Computes the Levenshtein distance between s1 and s2 using the Wagner-Fischer algorithm. Returns the Levenshtein distance as a number.

License

This project is licensed under the MIT License.

wagner_fischer's People

Contributors

sshahzaiib avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.