14 template <
typename Context>
15 mutable_automaton<Context>
18 static_assert(Context::is_lat,
19 "levenshtein: labelset must be a tupleset");
21 "levenshtein: labelset must have 2 tapes");
22 static_assert(std::tuple_element<0, typename Context::labelset_t::valuesets_t>::type::has_one(),
23 "levenshtein: first tape must have empty word");
24 static_assert(std::tuple_element<1, typename Context::labelset_t::valuesets_t>::type::has_one(),
25 "levenshtein: second tape must have empty word");
26 static_assert(std::is_same<typename Context::weightset_t, nmin>::value,
27 "levenshtein: weightset must be nmin");
28 using label_t =
typename Context::labelset_t::value_t;
29 const auto& ls = *ctx.labelset();
30 const auto& ls1 = ls.template set<0>();
31 const auto& ls2 = ls.template set<1>();
32 const auto& ws = *ctx.weightset();
39 auto s = res->new_state();
42 for (
auto l : letters)
43 res->new_transition(s, s, label_t{l, ls2.one()}, 1);
44 for (
auto l : letters2)
45 res->new_transition(s, s, label_t{ls1.one(), l}, 1);
46 for (
auto l : letters)
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.
std::shared_ptr< const detail::context_base > context
A dyn::context.
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
static dyn::context ctx(const driver &d)
Get the context of the driver.
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)
automaton levenshtein(const dyn::context &ctx)
Bridge.
std::shared_ptr< detail::automaton_base > automaton
size_t size(const ExpSet &rs, const typename ExpSet::value_t &r)
mutable_automaton< Context > levenshtein(const Context &ctx)
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton