liblevenshtein
4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
memoized_distance.h
Go to the documentation of this file.
1
#ifndef LIBLEVENSHTEIN_DISTANCE_MEMOIZED_DISTANCE_H
2
#define LIBLEVENSHTEIN_DISTANCE_MEMOIZED_DISTANCE_H
3
4
#include <shared_mutex>
5
#include <string>
6
#include <unordered_map>
7
8
#include "
liblevenshtein/distance/distance.h
"
9
#include "
liblevenshtein/distance/symmetric_pair.h
"
10
11
namespace
liblevenshtein::distance
{
12
16
class
MemoizedDistance
:
public
Distance
{
17
protected
:
18
30
auto
get
(
const
SymmetricPair
&
key
, std::size_t &
distance
) ->
bool
;
31
40
auto
set
(
const
SymmetricPair
&
key
,
const
std::size_t &
distance
)
41
-> std::size_t;
42
52
static
auto
f
(
const
std::string &
u
, std::size_t
t
) -> std::string;
53
54
private
:
55
57
std::unordered_map<SymmetricPair, std::size_t>
memo
;
58
60
mutable
std::shared_mutex
mutex
;
61
};
62
63
}
// namespace liblevenshtein::distance
64
65
#endif
// LIBLEVENSHTEIN_DISTANCE_MEMOIZED_DISTANCE_H
liblevenshtein::distance::Distance
Metric that measures the edit distance between two terms, denoted d(v,w).
Definition
distance.h:21
liblevenshtein::distance::MemoizedDistance
Memoizes the distance between pairs of terms.
Definition
memoized_distance.h:16
liblevenshtein::distance::MemoizedDistance::get
auto get(const SymmetricPair &key, std::size_t &distance) -> bool
Collects the memoized distance between the pair of terms represented by the SymmetricPair if the dist...
Definition
memoized_distance.cpp:9
liblevenshtein::distance::MemoizedDistance::f
static auto f(const std::string &u, std::size_t t) -> std::string
Returns the suffix of from position .
Definition
memoized_distance.cpp:26
liblevenshtein::distance::MemoizedDistance::set
auto set(const SymmetricPair &key, const std::size_t &distance) -> std::size_t
Memoizes the distance between the SymmetricPair of terms for future reference.
Definition
memoized_distance.cpp:19
liblevenshtein::distance::MemoizedDistance::memo
std::unordered_map< SymmetricPair, std::size_t > memo
Memoized distances between pairs of terms.
Definition
memoized_distance.h:57
liblevenshtein::distance::MemoizedDistance::mutex
std::shared_mutex mutex
Coordinates memoization among threads.
Definition
memoized_distance.h:60
liblevenshtein::distance::SymmetricPair
Represents a pair of terms sorted, lexicographically, in ascending order.
Definition
symmetric_pair.h:12
distance.h
query
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Definition
main.cpp:25
liblevenshtein::distance
Memoized, recursive distance metrics typically used to evaluate the correctness of Levenshtein automa...
Definition
namespaces.dox:16
liblevenshtein::distance
auto distance(State *state, std::size_t query_length) -> std::size_t
Infers the Levenshtein distance from the given State and query length.
symmetric_pair.h
src
liblevenshtein
distance
memoized_distance.h
Generated by
1.10.0