4 changed files with 52 additions and 12 deletions
@ -0,0 +1,11 @@
|
||||
!@import wgt wordgen_tmpl; |
||||
|
||||
!word_set = ${ |
||||
who = $[$[1, "You"], $[1, "I"], $[1, "Bob"], $[1, "Alice"]], |
||||
where = $[$[1, "to the mall"], $[1, "to the cinema"], $[4, "shopping"]], |
||||
}; |
||||
|
||||
range 1 10 1 {|| |
||||
std:displayln ~ |
||||
wgt:tmpl_gen word_set "{who} wants to go {where}."; |
||||
} |
@ -0,0 +1,25 @@
|
||||
!@import std std; |
||||
!@import wlambda; |
||||
!@import wg wordgen; |
||||
|
||||
!sm = std:rand:split_mix64_new[]; |
||||
|
||||
!new_gen = {!(word_set, tmpl) = @; |
||||
wg:gen $[tmpl] word_set { |
||||
std:rand:split_mix64_next_open01 sm |
||||
}; |
||||
}; |
||||
|
||||
!@export tmpl_gen = {!(word_set, s) = @; |
||||
(std:fold $[] { |
||||
!out = _1; |
||||
!tmpl_word = _.1; |
||||
std:push out _.0; |
||||
(not ~ is_none tmpl_word) { |
||||
std:push out ~ new_gen word_set tmpl_word; |
||||
}; |
||||
_1 |
||||
} ~ std:re:map $q$([^{]*)(?:\{([^}]+)\})?$ { |
||||
$[_.1, _.2] |
||||
} s) | std:str:join ""; |
||||
}; |
Loading…
Reference in new issue