Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wooorm/levenshtein.c
Levenshtein algorithm in C
https://github.com/wooorm/levenshtein.c
edit-distance fuzzy-matching fuzzy-search levenshtein levenshtein-distance similarity string-matching
Last synced: 1 day ago
JSON representation
Levenshtein algorithm in C
- Host: GitHub
- URL: https://github.com/wooorm/levenshtein.c
- Owner: wooorm
- License: mit
- Created: 2015-05-03T09:00:11.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2022-09-08T17:18:00.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T16:09:00.122Z (3 months ago)
- Topics: edit-distance, fuzzy-matching, fuzzy-search, levenshtein, levenshtein-distance, similarity, string-matching
- Language: C
- Size: 22.5 KB
- Stars: 80
- Watchers: 8
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: funding.yml
- License: license
Lists
- awesome-c-zh - levenstein.c - [Levenstein distance](https://en.wikipedia.org/wiki/Levenshtein_distance)算法实现。[](https://spdx.org/licenses/MIT.html)。 (字符串操作 / 模板库)
README
# levenshtein(3)
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]Vladimir Levenshtein’s edit distance algorithm[1][wiki] as a C library. There’s also a CLI: [levenshtein(1)][cli], and a [JavaScript version][js].
## Installation
[CLib][]:
```sh
$ clib install wooorm/levenshtein.c
```Or clone the repo.
## Usage
### `size_t levenshtein(const char *a, const char *b);`
```c
#include
#include "levenshtein.h"int
main(int argc, char **argv) {
char *a = argv[1];
char *b = argv[2];if (argc < 3) {
fprintf(stderr, "\033[31mLevenshtein expects two arguments\033[0m\n");return 1;
}printf("%zu\n", levenshtein(a, b));
}
```### `size_t levenshtein_n(const char *a, const size_t length, const char *b, const size_t bLength);`
``` c
#include
#include "levenshtein.h"int
main() {
const char *a = "foobar";
const char *b = "hello";printf("%zu\n", levenshtein_n(a, 6, b, 5));
}
```## License
[MIT][] © [Titus Wormer][author]
[build-badge]: https://img.shields.io/travis/wooorm/levenshtein.c.svg
[build]: https://travis-ci.org/wooorm/levenshtein.c
[coverage-badge]: https://img.shields.io/coveralls/wooorm/levenshtein.c.svg
[coverage]: https://coveralls.io/github/wooorm/levenshtein.c
[wiki]: https://en.wikipedia.org/wiki/Levenshtein_distance
[cli]: https://github.com/wooorm/levenshtein
[js]: https://github.com/words/levenshtein-edit-distance
[mit]: license
[author]: https://wooorm.com
[clib]: https://github.com/clibs/clib