Closed shirish93 closed 8 years ago
@shirish93 What I would do is fake it by putting the same token multiple times.
[a, a, b, b, c, d, e]
is not Tracery but illustrates what I'm talking about -- a
and b
are 2x as likely as c
or d
or e
.
I like using a function that takes a map and returns the repeated array that Darius mentions.
function weighted(dict) { var out = [] for (var key in dict) { for (var i = 0; i < dict[key]; i++) { out.push(key) } } return out }
weighted({a: 2, b: 2, c: 1, d: 1, e: 1})
returns
[a, a, b, b, c, d, e]
On Tue, May 10, 2016 at 8:59 PM Darius Kazemi notifications@github.com wrote:
@shirish93 https://github.com/shirish93 What I would do is fake it by putting the same token multiple times.
[a, a, b, b, c, d, e] is not Tracery but illustrates what I'm talking about -- a and b are 2x as likely as c or d or e.
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/galaxykate/tracery/issues/23#issuecomment-218335055
Fair. Closing the issue. Thanks everyone!
Hello,
I checked the documentation and was unable to find it, so this is probably a feature request. Does it make sense to add a feature to mess around with the likelihood of certain tokens? For example, if one wanted to make a faux astrology bot (not to give you any ideas, @dariusk ), and wanted to use some tokens ("Mars", "Venus") more than others?
THANKS!
Shirish