Lingua::Awkwords::OneOf - random choice from a list of items
This module is not typically used directly, as it will be created and called as part of the pattern parse and then render phases of other code.
Container object for a list of items; upon render one of these items will be picked at random and have render called on it. Whatever that returns will be returned, minus whatever any filters may remove.
List of filters, if any. Use add_filters to set these.
String to replaced filtered values with, the empty string by default.
Where the Math::Random::Discrete object to provide weighted random choices is stored.
Choices are stored here as an array reference.
List of weights for each of the choices.
Adds the given value and its weight to the choices.
Adds one or more strings as a filter for the render phase. These limit what a unit can generate, e.g. [x/y/z]^x would replace a result of x with the empty string.
[x/y/z]^x
x
This is used by the add method to invalidate the picker object; call this method if you have manually fiddled with the alts or weights after making a render call.
Constructor.
Picks a random choice and in turn calls render on that, then applies any filters present on that result.
Calls the callback function with itself as the argument, then calls walk on all of the available choices.
Please report any bugs or feature requests to bug-lingua-awkwords at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Lingua-Awkwords.
bug-lingua-awkwords at rt.cpan.org
Patches might best be applied towards:
https://github.com/thrig/Lingua-Awkwords
None at this time.
Lingua::Awkwords, Lingua::Awkwords::Parser
Math::Random::Discrete
thrig - Jeremy Mates (cpan:JMATES) <jmates at cpan.org>
<jmates at cpan.org>
Copyright (C) 2017 by Jeremy Mates
This program is distributed under the (Revised) BSD License: http://www.opensource.org/licenses/BSD-3-Clause
To install Lingua::Awkwords, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lingua::Awkwords
CPAN shell
perl -MCPAN -e shell install Lingua::Awkwords
For more information on module installation, please visit the detailed CPAN module installation guide.