PHPackages                             datingvip/damerau-levenshtein - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. datingvip/damerau-levenshtein

ActiveLibrary

datingvip/damerau-levenshtein
=============================

Get text similarity level with Damerau-Levenshtein distance

v3.0.2(4y ago)03.5k↓14.3%MITPHPPHP &gt;=7.1.0

Since Oct 22Pushed 4y agoCompare

[ Source](https://github.com/DatingVIP/damerau-levenshtein)[ Packagist](https://packagist.org/packages/datingvip/damerau-levenshtein)[ Docs](http://github.com/DatingVIP/damerau-levenshtein)[ RSS](/packages/datingvip-damerau-levenshtein/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (15)Used By (0)

Damerau Levenshtein
===================

[](#damerau-levenshtein)

[![CI](https://github.com/Oefenweb/damerau-levenshtein/workflows/CI/badge.svg)](https://github.com/Oefenweb/damerau-levenshtein/actions?query=workflow%3ACI)[![PHP 7 ready](https://camo.githubusercontent.com/bcea3691ba59923341f2469a5a20893485fc89d994288458c5dbffcfe6b4de0f/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f4f6566656e7765622f64616d657261752d6c6576656e73687465696e2f62616467652e737667)](https://travis-ci.org/Oefenweb/damerau-levenshtein)[![codecov](https://camo.githubusercontent.com/6921b284d0cc362128327a062f4dd69015f55dc8871b45b364f0552931681974/68747470733a2f2f636f6465636f762e696f2f67682f4f6566656e7765622f64616d657261752d6c6576656e73687465696e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Oefenweb/damerau-levenshtein)[![Packagist downloads](https://camo.githubusercontent.com/f9605d3ba837a7fc338955b0eed97af84629dc23d41dbde3b81006c40ac4a46e/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4f6566656e7765622f64616d657261752d6c6576656e73687465696e2e737667)](https://packagist.org/packages/oefenweb/damerau-levenshtein)[![Code Climate](https://camo.githubusercontent.com/8a61a17e6fe3b00ddbc966e2007a906f50afd658b795a9a69499d6b754a6561b/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f4f6566656e7765622f64616d657261752d6c6576656e73687465696e2f6261646765732f6770612e737667)](https://codeclimate.com/github/Oefenweb/damerau-levenshtein)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5d2b6a6b9948728c6f79210c81e963a5fcf0926ba27b4ad9f64f4fa45b15418f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4f6566656e7765622f64616d657261752d6c6576656e73687465696e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Oefenweb/damerau-levenshtein/?branch=master)

Get text similarity level with Damerau-Levenshtein distance.

Requirements
------------

[](#requirements)

- PHP 7.1.0 or greater.

Installation
------------

[](#installation)

`composer require oefenweb/damerau-levenshtein`

Usage
-----

[](#usage)

```
$pattern = 'foo bar';
$string  = 'fuu baz';

$damerauLevenshtein = new DamerauLevenshtein($pattern, $string);

$damerauLevenshtein->getSimilarity(); // absolute edit distance; == 3

$damerauLevenshtein->getRelativeDistance(); // relative edit distance; == 0.57142857142857

$damerauLevenshtein->getMatrix(); // get complete distance matrix
/* ==
 * [
 *   [0,1,2,3,4,5,6,7],
 *   [1,0,1,2,3,4,5,6],
 *   [2,1,1,2,3,4,5,6],
 *   [3,2,2,2,3,4,5,6],
 *   [4,3,3,3,2,3,4,5],
 *   [5,4,4,4,3,2,3,4],
 *   [6,5,5,5,4,3,2,3],
 *   [7,6,6,6,5,4,3,3],
 * ]
 */

$damerauLevenshtein->displayMatrix(); // get readable and formatted distance matrix
/*
 *   '  foo bar' . PHP_EOL
 * . ' 01234567' . PHP_EOL
 * . 'f10123456' . PHP_EOL
 * . 'u21123456' . PHP_EOL
 * . 'u32223456' . PHP_EOL
 * . ' 43332345' . PHP_EOL
 * . 'b54443234' . PHP_EOL
 * . 'a65554323' . PHP_EOL
 * . 'z76665433'
 */
```

Different costs are supported by the constructor and getters / setters.

Character comparison (equal check) can easily be overridden by parent class (see `DamerauLevenshtein::compare`).

For more examples look at `/tests/DamerauLevenshteinTest.php` or **RTFC**.

License
-------

[](#license)

MIT

#### Author Information

[](#author-information)

Mischa ter Smitten (based on work of [Ph4r05](http://www.phpclasses.org/package/7021-PHP-Get-text-similarity-level-with-Damerau-Levenshtein.html))

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 93.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~204 days

Recently: every ~276 days

Total

14

Last Release

1563d ago

Major Versions

v1.0.2 → v2.0.02015-06-09

v2.1.5 → v3.0.02019-01-23

PHP version history (4 changes)v1.0.0PHP &gt;=5.3.10

v2.1.0PHP &gt;=5.4.16

v3.0.0PHP &gt;=7.0.0

v3.0.1PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b3d0432439843a2a063fec06efcf774d2193469dd51d72cfbb6457f6301004cf?d=identicon)[kornrunner](/maintainers/kornrunner)

---

Top Contributors

[![tersmitten](https://avatars.githubusercontent.com/u/3392962?v=4)](https://github.com/tersmitten "tersmitten (81 commits)")[![mvdriel](https://avatars.githubusercontent.com/u/408052?v=4)](https://github.com/mvdriel "mvdriel (4 commits)")[![kornrunner](https://avatars.githubusercontent.com/u/725986?v=4)](https://github.com/kornrunner "kornrunner (2 commits)")

---

Tags

distancesimilaritylevenshteindamerau

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/datingvip-damerau-levenshtein/health.svg)

```
[![Health](https://phpackages.com/badges/datingvip-damerau-levenshtein/health.svg)](https://phpackages.com/packages/datingvip-damerau-levenshtein)
```

###  Alternatives

[oefenweb/damerau-levenshtein

Get text similarity level with Damerau-Levenshtein distance

40265.8k4](/packages/oefenweb-damerau-levenshtein)[mjaschen/phpgeo

Simple Yet Powerful Geo Library

1.6k8.6M22](/packages/mjaschen-phpgeo)[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.3M26](/packages/league-geotools)[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4485.3M4](/packages/martin-georgiev-postgresql-for-doctrine)[edgaras/strsim

Collection of string similarity and distance algorithms in PHP including Levenshtein, Damerau-Levenshtein, Jaro-Winkler, and more

2423.0k](/packages/edgaras-strsim)[fza/mysql-doctrine-levenshtein-function

Provides the `LEVENSHTEIN()` and `LEVENSHTEIN\_RATIO()` MySQL functions for Doctrine2.

47115.8k1](/packages/fza-mysql-doctrine-levenshtein-function)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
