Lingua::Conjunction - Convert lists into linguistic conjunctions and fill them into a template
say conjunction <chair>; # chair
say conjunction <chair spoon>; # chair and spoon
say conjunction <chair spoon window>; # chair, spoon, and window
# "Tom, a man; Tiffany, a woman; and GumbyBRAIN, a bot"
say conjunction 'Tom, a man', 'Tiffany, a woman', 'GumbyBRAIN, a bot';
# These are reports for May, June, and August
say conjunction <May June August>, :str('These [is|are] report[|s] for |list|');
# "Jacques, un garcon; Jeanne, une fille et Spot, un chien"
say conjunction 'Jacques, un garcon', 'Jeanne, une fille', 'Spot, un chien',
Provides a way to make it easy to prepare a string containing a list of items, where that string is meant to be read by a human.
say conjunction <chair spoon>;
say conjunction <May June August>, :str('Report[|s] for |list|'),
:lang<fr>, :!last, :sep<·>, :alt<°>, :con<aaand>, :dis<ooor>, :type<or>;
Returns a string with the given list of items joined based on the configuration specified by the named arguments, which are as follows:
Specifies an alternative separator to use when at least one of the items contains
sep separator. Defaults to
; (a semicolon).
Short for conjunction. The term to use when joining the last item to the previous one, when
type argument is set to value
and. By default is set based on value of
Short for disjunction. The term to use when joining the last item to the previous one, when
type argument is set to value
or. By default is set based on value of
Takes a string representing the code of the language to use. This will pre-set
last arguments. Defaults to
en. Currently supported languages and the defaults they pre-set are as follows (language is the first two-letter key on the left; that's what you'd specify as
Specifies whether to use
sep when joining the penultimate and last elements of the list, when the number of elements is more than 2. In English, this is what's known as Oxford Comma. By default is set based on value of
The primary item separator to use. Defaults to
, (a comma).
say conjunction <May June August>, :str('Report[|s] for |list|');
say conjunction <Squishy Slushi Sushi>,
:str('Octop[us|i] [is|are] named |list|');
Specifies a template to use when generating the string. You can use special sequence
octop[us|i]) where string to the left of the
| will be used when the list contains just one item and the string to the right will be used otherwise. The other special sequence is
|list| that will be replaced with the "conjuncted" items of the list. Defaults to
Takes either value
and or value
or. Specifies whether words specified by
con or by
dis arguments should be used when joining the last two elements of the list.
This module was inspired by Perl's Lingua::Conjunction and and List::ToHumanString. Some of the internal data was shamelessly
stolen borrowed from Lingua::Conjunction's guts.
The rest is by Zoffix Znet (http://zoffix.com/)
COPYRIGHT AND LICENSE
Copyright 2015 - 2017 Zoffix Znet
Copyright 2018 - 2023 Raku Community
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.