15 template <
typename Context>
16 mutable_automaton<Context>
19 static_assert(Context::is_lat,
20 "levenshtein: labelset must be a tupleset");
22 "levenshtein: labelset must have 2 tapes");
23 static_assert(Context::labelset_t::template valueset_t<0>::has_one(),
24 "levenshtein: first tape must have empty word");
25 static_assert(Context::labelset_t::template valueset_t<1>::has_one(),
26 "levenshtein: second tape must have empty word");
27 static_assert(std::is_same<typename Context::weightset_t, nmin>::value,
28 "levenshtein: weightset must be nmin");
29 using label_t =
typename Context::labelset_t::value_t;
30 const auto& ls = *ctx.labelset();
31 const auto& ls1 = ls.template set<0>();
32 const auto& ls2 = ls.template set<1>();
33 const auto& ws = *ctx.weightset();
39 auto s = res->new_state();
43 for (
auto l : letters1)
44 res->new_transition(s, s, label_t{l, ls2.one()}, 1);
46 for (
auto l : letters2)
47 res->new_transition(s, s, label_t{ls1.one(), l}, 1);
49 for (
auto l : letters1)
50 for (
auto l2 : letters2)
51 res->new_transition(s, s, label_t{l, l2}, !ls1.equal(l, l2));
64 template <
typename Context>
68 const auto& c = ctx->as<Context>();
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
mutable_automaton< Context > levenshtein(const Context &ctx)
The Levenshtein automaton for a given context.
std::shared_ptr< const detail::context_base > context
A dyn::context.
std::vector< typename Cont::value_type > make_vector(const Cont &cont)
The content of cont as a vector.
automaton levenshtein(const dyn::context &ctx)
Bridge.
std::shared_ptr< detail::automaton_base > automaton
static dyn::context ctx(const driver &d)
Get the context of the driver.
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)