Weighted finite-state transducer data model and graph algorithms in MoonBit
moon add okMambaOut/moon-wfst@0.1.2import {
"okMambaOut/moon-wfst" @wfst,
}moon run --target wasm-gc examples/speech_lattice
moon run --target wasm-gc examples/morphology
moon run --target wasm-gc examples/ocr_constraints| 示例 | 输入与处理流程 | 合成样例的确定结果 |
|---|---|---|
| 语音候选格 | 将识别候选格与词法映射组合,选择最低成本接受路径。 | cat,总成本 6。 |
| 形态分析 | 为不规则词形 went 的多个词素分析排序,提取低成本结果。 | go+PAST,成本 1。 |
| OCR 格式约束 | 将六格字符候选与格式转导机组合,结合字形混淆成本重新评分。 | NB0158,总成本 6。 |
moon info
moon fmt --check
moon check --target wasm-gc --deny-warn
moon check --target wasm --deny-warn
moon check --target js --deny-warn
moon check --target native --deny-warn
moon build --target wasm-gc --deny-warn
moon test --target wasm-gc --deny-warnpub struct AcceptingPath[W] {
final_weight : W
total : W
// private fields
}pub struct PathOrder[W] {
compare : (W, W) -> Int
is_nonnegative : (W) -> Bool
is_zero : (W) -> Bool
}pub(all) struct Semiring[W] {
zero : W
one : W
plus : (W, W) -> W
times : (W, W) -> W
}pub(all) struct TransducerStats {
state_count : Int
arc_count : Int
epsilon_input_arc_count : Int
epsilon_output_arc_count : Int
final_state_count : Int
max_out_degree : Int
reachable_state_count : Int
coaccessible_state_count : Int
has_start : Bool
} derive(Eq)fn[W] accepts_pair(transducer : Transducer[W], input : Array[String], output : Array[String], is_zero : (W) -> Bool) -> Result[Bool, WfstError]fn[W] add_arc(builder : TransducerBuilder[W], source : Int, input : Label, output : Label, destination : Int, weight : W) -> Result[Unit, WfstError]fn[W] path_order(compare : (W, W) -> Int, is_nonnegative : (W) -> Bool, is_zero : (W) -> Bool) -> PathOrder[W]fn[W] reachable_states_from(transducer : Transducer[W], root : Int) -> Result[Array[Bool], WfstError]fn[W] shortest_path(transducer : Transducer[W], order : PathOrder[W]) -> Result[AcceptingPath[W], WfstError]fn[W] shortest_paths_in_dag(transducer : Transducer[W], order : PathOrder[W], limit : Int) -> Result[Array[AcceptingPath[W]], WfstError]fn[W] transducer_arcs_from(transducer : Transducer[W], state : Int) -> Result[Array[Arc[W]], WfstError]fn[W] transducer_incoming_arcs(transducer : Transducer[W], destination : Int) -> Result[Array[(Int, Arc[W])], WfstError]Install
Download zipWeighted finite-state transducer data model and graph algorithms in MoonBit