12 template <
typename Context>
13 mutable_automaton<Context>
16 static_assert(Context::is_lat,
17 "levenshtein: labelset must be a tupleset");
19 "levenshtein: labelset must have 2 tapes");
20 static_assert(Context::labelset_t::template valueset_t<0>::has_one(),
21 "levenshtein: first tape must have empty word");
22 static_assert(Context::labelset_t::template valueset_t<1>::has_one(),
23 "levenshtein: second tape must have empty word");
24 static_assert(std::is_same<typename Context::weightset_t, nmin>::value,
25 "levenshtein: weightset must be nmin");
26 using label_t =
typename Context::labelset_t::value_t;
27 const auto& ls = *ctx.labelset();
28 const auto& ls1 = ls.template set<0>();
29 const auto& ls2 = ls.template set<1>();
30 const auto& ws = *ctx.weightset();
36 auto s = res->new_state();
40 for (
auto l : letters1)
41 res->new_transition(s, s, label_t{l, ls2.one()}, 1);
43 for (
auto l : letters2)
44 res->new_transition(s, s, label_t{ls1.one(), l}, 1);
46 for (
auto l : letters1)
47 for (
auto l2 : letters2)
48 res->new_transition(s, s, label_t{l, l2}, !ls1.equal(l, l2));
61 template <
typename Context>
65 const auto& c = ctx->
as<Context>();
std::vector< typename Cont::value_type > make_vector(const Cont &cont)
The content of cont as a vector.
mutable_automaton< Context > levenshtein(const Context &ctx)
The Levenshtein automaton for a given context.
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)
auto & as()
Downcast to the exact type.
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
Template-less root for contexts.
automaton levenshtein(const dyn::context &ctx)
Bridge.