☰

*ON THIS PAGE*# A fuzzy search and word metric library

**Author(s):** Isabel Garcia-Contreras.

## Usage and interface

## Documentation on exports

*Meta-predicate* with arguments: `fuzzy_search(?,pred(1),pred(3),?,?)`.

## Documentation on imports

This module has the following direct dependencies:## Known bugs and planned improvements

The `fuzzy_search` library provides a set of predicates which calculate distance between words implementing levenshtein distance and damerau-levenshtein distance.

This is a simple example:

?- levenshtein_dist(append, apend, D). D = 1 ? yes ?- levenshtein_dist(append, appedn, D). D = 2 ? yes ?- ?- damerau_lev_dist(length, lenght, D). D = 1 ? yes ?-

**Library usage:**`:- use_module(library(fuzzy_search)).`**Exports:***Predicates:*`levenshtein_dist/3`,`damerau_lev_dist/3`,`fuzzy_search/5`.

PREDICATElevenshtein_dist/3

Usage:`levenshtein_dist(Word1,Word2,Distance)`

Computes the levenshtein Distance between Word1 and Word2

*The following properties should hold at call time:*

(`term_typing:atom/1`)Word1 is currently instantiated to an atom.

(`term_typing:atom/1`)Word2 is currently instantiated to an atom.

(`term_typing:var/1`)Distance is a free variable.*The following properties should hold upon exit:*

(`term_typing:atom/1`)Word1 is currently instantiated to an atom.

(`term_typing:atom/1`)Word2 is currently instantiated to an atom.

(`basic_props:num/1`)Distance is a number.

PREDICATEdamerau_lev_dist/3

Usage:`damerau_lev_dist(Word1,Word2,Distance)`

Computes the Damerau-Levenshtein Distance between Word1 and Word2

*The following properties should hold at call time:*

(`term_typing:atom/1`)Word1 is currently instantiated to an atom.

(`term_typing:atom/1`)Word2 is currently instantiated to an atom.

(`term_typing:var/1`)Distance is a free variable.*The following properties should hold upon exit:*

(`term_typing:atom/1`)Word1 is currently instantiated to an atom.

(`term_typing:atom/1`)Word2 is currently instantiated to an atom.

(`basic_props:num/1`)Distance is a number.

PREDICATEfuzzy_search/5

Usage:`fuzzy_search(Word,Generator,Metric,MaxDistance,Suggestion)`

Proposes atoms generated by Generator which have MaxDistance differences with Word

*The following properties should hold at call time:*

(`term_typing:atom/1`)Word is currently instantiated to an atom.

(`term_typing:atom/1`)Generator is currently instantiated to an atom.

(`term_typing:atom/1`)Metric is currently instantiated to an atom.

(`basic_props:num/1`)MaxDistance is a number.

(`term_typing:var/1`)Suggestion is a free variable.*The following properties should hold upon exit:*

(`term_typing:atom/1`)Word is currently instantiated to an atom.

(`term_typing:atom/1`)Generator is currently instantiated to an atom.

(`term_typing:atom/1`)Metric is currently instantiated to an atom.

(`basic_props:num/1`)MaxDistance is a number.

(`term_typing:atom/1`)Suggestion is currently instantiated to an atom.

*System library modules:*`lists`,`hiordlib`.*Packages:*`prelude`,`initial`,`condcomp`,`assertions`,`assertions/assertions_basic`,`hiord`.

- Using 1000000 as inf limits word size to 1000000-1

Generated with LPdoc using Ciao