- OBJECT METHODS
- INTERNAL METHODS
- SEE ALSO
- COPYRIGHT & LICENSE
Template::Plugin::Lingua::EN::Inflect - Interface to Lingua::EN::Inflect module
[% USE infl = Lingua.EN.Inflect; -%] [% FILTER inflect(number => 42); -%] There PL_V(was) NO(error). PL_ADJ(This) PL_N(error) PL_V(was) fatal. [% END; -%] [% "... and "; infl.ORD(9); "ly..." %] # Output: # There were 42 errors. # These errors were fatal. # ... and 9thly...
The Lingua::EN::Inflect is an interface to Damian Conway's Linua::EN::Inflect Perl module, which provides plural inflections, "a"/"an" selection for English words, and manipulation of numbers as words.
The plugin provides an 'inflect' filter, which can be used to interpolate inflections in a string. The NUM() function sets a persistent default value to be used whenever an optional number argument is omitted. The number to be used for a particular invocation of 'inflect' can also be specified with a 'number' option.
For the full gory details of the inflection functionality refer to the Lingua::EN::Inflect manual.
prepends the appropriate indefinite article to a word, depending on its pronunciation. If the second argument is provided and its value is numeric and not 1 then the value of the second argument is used instead.
given a word and an optional count, returns the count followed by the correctly inflected word
sets a persistent default number value, which is subsequently used whenever an optional second number argument is omitted. The default value thus set can subsequently be removed by calling
NUM()with no arguments.
NUM()normally returns its first argument, however if
NUM()is called with a second argument that is defined and evaluates to false then
NUM()returns an empty string.
takes a number (cardinal or ordinal) and returns an English represen- tation of that number. In a scalar context a string is returned. In a list context each comma-separated chunk is returned as a separate element.
takes a single argument and forms its ordinal equivalent. If the argument isn't a numerical integer, it just adds "-th".
returns the present participle for a third person singluar verb
PART_PRES("runs"); # returns "running"
returns the plural of a singular English noun, pronoun, verb or adjective.
returns the plural of a singular English noun or pronoun.
returns the plural conjugation of the singular form of a conjugated verb.
returns the plural form of a singular form of certain types of adjectives.
Finish off documenting the object methods.
Provide tests for all methods in the test suite.
It would also be nice to have methods that spelled out numbers that were less than a certain threshold and that formatted large numbers with commas, for example:
inflect("There PL_V(was) NO(error).", number => 0); # outputs: "There were no errors." inflect("There PL_V(was) NO(error).", number => 1); # outputs: "There was one errors." inflect("There PL_V(was) NO(error).", number => 3); # outputs: "There were three errors." inflect("There PL_V(was) NO(error).", number => 1042); # outputs: "There were 1,042 errors."
This would require changes to the Lingua::EN::Inflect module.
This distribution was originally created by Andrew Ford. Sadly in early 2014, Andrew was diagnosed with Pancreatic Cancer and passed away peacfully at home on 25th April 2014.
One of his wishes was for his OpenSource work to continue. At his funeral, many of his colleagues and friends, spoke of how he felt like a person of the world, and how he embrace the idea of OpenSource being for the benefit of the world.
Anyone wishing to donate in memory of Andrew, please consider the following charities:
- Dignity in Dying - http://www.dignityindying.org.uk/
- Marie Curie Cancer Care - http://www.mariecurie.org.uk/
Original Author: Andrew Ford 2005-2014 Current Maintainer: Barbie <email@example.com> 2014
Andrew Ford wrote the original plugin code (basing it heavily on the Template::Plugin::Autoformat code).
Damian Conway <firstname.lastname@example.org> wrote the Lingua::EN::Inflect module, which does all the clever stuff.
Copyright (C) 2005-2014 Andrew Ford Copyright (C) 2014-2015 Barbie for Miss Barbell Productions.
This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2.