Bounded example-guided string program synthesis, disagreement selection and portable recipes in MoonBit.

moon check --deny-warn
moon test --deny-warn
moon run cmd/demo
node scripts/build.mjs
node scripts/serve.mjs| 使用者与问题 | 输入与操作 | 输出与验证 |
|---|---|---|
| 小商家/运营整理供应商复合编码 | examples/products/input.csv;提供两个型号/颜色样例,分别选择规则 | 型号 0012、123456 等保留前导零,颜色转大写;另外两行不参与训练,逐值检查 |
| 活动组织者生成名单标签 | examples/labels/input.csv;用姓名、班级示范 A1 / 陈雨,另外复制编号字段 | 新行生成 C20 / 赵晨,编号不变;测试重排列后重用配方仍一致 |
| 内容创作者整理音视频文件 | examples/media/input.csv;标注两个日期和 take 编号 | 未见的 20240229 正确变为 2024-02-29;invalid.csv 中 20260229 报错并停止 CSV 导出 |
node scripts/integration.mjs| 数据与使用者 | 操作与结果 | 验证范围 |
|---|---|---|
| IANA tzdb 2025b:应用设置页开发者 | 312 个时区标识,示范区域、末级地点,生成可按区域查询的目录 | 3 个字段,每字段 3 条训练,其余 309 条逐值验证 |
| Unicode CLDR 48:国际化开发者 | 766 个 locale,生成语言分组、资源路径和原始标识 | 3 个字段,每字段 3 条训练,其余 763 条逐值验证 |
| github/gitignore:IDE 模板目录开发者 | 312 个多层路径,生成文件名、去扩展名的模板名称和原路径 | 模板名称先有 3 条训练,按分歧提示补 C 和 C++ 两条;其余 307 条验证 |
python scripts/import-public-data.py
node scripts/public-data-test.mjs
python scripts/verify-sqlite.pynode bin/exampleloom.mjs learn --data examples/products/input.csv --examples examples/products/model-labels.json --out candidates.json
node bin/exampleloom.mjs recipe --report candidates.json --choose 0 --name model --out product.recipe.json
node bin/exampleloom.mjs apply --data examples/products/input.csv --recipe product.recipe.json --out product.result.csvlet report = @loom.synthesize([
{ input: ["订单-0012"], output: "0012" },
{ input: ["订单-123456"], output: "123456" },
])
// 先检查 report.truncated、候选表达式和 disagreements,再选择。
let output = @loom.evaluate(report.candidates[0].expression, ["订单-00987"])moon fmt --check
moon check --deny-warn --target all
moon test --deny-warn --target wasm-gc
moon test --deny-warn --target js
moon test --deny-warn --target wasm
moon infopub(all) struct SearchOptions {
max_candidates : Int
max_parts : Int
max_atom_evaluations : Int
max_steps : Int
max_frontier : Int
}fn handle(request : String) -> Stringfn synthesize(examples : Array[Example], options? : SearchOptions, separators? : Array[String]) -> SearchReport raise LoomErrorInstall
Download zipBounded example-guided string program synthesis, disagreement selection and portable recipes in MoonBit.