Giter Club home page Giter Club logo

edit_distance's Introduction

Note: I am currently doing development for edit_distance() on my fork of Boost.Algorithm:

edit_distance

A C++ Boost implementation of the edit distance between two sequences -- aka Levenshtein distance, aka string distance, aka string difference.

The edit_distance library provides a function edit_distance():

  • edit_distance(seq1, seq2) returns the edit distance between two sequences, which may be any C++ range.
  • edit_distance(seq1, seq2, _script = out) returns the edit distance, and calls special handler methods from object 'out' on the correspondiung "script" of edit operations.

These functions are based on a variation of the Dijkstra Single Source Shortest Path algorithm, optimized for the particular structure of an edit graph. They are efficient on long sequences with localized areas of differences (e.g. computing the diff of two similar files). Whenever conditions permit, an even faster specialized distance algorithm is automatically applied: An O(ND) Difference Algorithm and its Variations by Eugene W. Myers Dept of Computer Science, University of Arizona

A user specified edit operation cost function can be provided:

// provide a customized cost for insertion, deletion and/or substitution
int d = edit_distance(s1, s2, _cost=my_cost_type());

// use a customized definition of element equality:
int d = edit_distance(s1, s2, _equal=my_equal());

Sequences may be any kind of C++ range object, and may be mixed:

// Any forward range can be provided to these functions.
// Sequence element types are not required to be exactly equal, as long as they are compatible.
int d = edit_distance(my_vector, my_list | boost::adaptors::reversed);

edit_distance's People

Contributors

erikerlandson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

libkeiser

edit_distance's Issues

reduce redundancy in method names

examples:

in a cost function object, 'cost_ins' could just be 'insertion', or in an output function object, 'output_ins' could also just be 'insertion'

Support cost functions with awareness of edit history

The best way to support applications such as this:

Comparing Hierarchical Data in External Memory
Sudarshan S. Chawathe
Department of Computer Science
University of Maryland
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.40.3307&rep=rep1&type=pdf

...is to allow the option of cost functions that can evaluate cost based on additional edit path history up to the current position. This is an extension of the standard edit distance model that assumes stateless cost functions.

Boost Review Wizards report

Boost - Dev - Review Wizard Status Report for January 2015 | Threaded View

According to the Boost Review Wizards report, you have a library in the review queue. Please consider raising the visibility of your library and encouraging people to experiment with while waiting for it to be reviewed. You can do this by filling out a form on the www.blincubator.com - the boost library incubator.

Robert Ramey
Robert Ramey Software Development
(805)569-3793
[email protected]
www.rrsd.com

Cost-limiting optional parameters

Some ideas for additional cost-limiting optional parameters

_max_cost : if edit cost reaches threshold, stop full search and just proceed to end with a fast cost-ignoring match

_max_time : similar to _max_cost, but triggers after some maximum time

Investigate bi-directional variation on the SSSP graph-based algorithms

The Myers algorithm implementation obtains some additional space and time efficiency by exploring edit paths forward and backward simultaneously, until forward and reverse paths meet.

My back-of-the-envelope calculations indicate a similar bi-directional approach might also be an improvement for the SSSP algorithms.

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.