GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TEMPLATE::PLUGIN::LINGUA::EN::INFLECT (3)

.ds Aq ’

NAME

Template::Plugin::Lingua::EN::Inflect - Interface to Lingua::EN::Inflect module

CONTENTS

SYNOPSIS



  [% 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...



DESCRIPTION

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.

OBJECT METHODS

infl.A($string, $opt_number) 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.

e.g. infl.A("idea") returns "an idea"

AN($string, $opt_number) synonym for A()
NO($string, $opt_arg) given a word and an optional count, returns the count followed by the correctly inflected word
NUM($string, $opt_arg) 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.
NUMWORDS($string, $opt_arg) 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.
ORD($number) takes a single argument and forms its ordinal equivalent. If the argument isn’t a numerical integer, it just adds -th.
PART_PRES($string, $opt_arg) returns the present participle for a third person singluar verb



    PART_PRES("runs");          # returns "running"



PL($string, $opt_arg) returns the plural of a singular English noun, pronoun, verb or adjective.
PL_N($string, $opt_arg) returns the plural of a singular English noun or pronoun.
PL_V($string, $opt_arg) returns the plural conjugation of the singular form of a conjugated verb.
PL_ADJ($string, $opt_arg) returns the plural form of a singular form of certain types of adjectives.
PL_eq($string, $opt_arg)
PL_N_eq($string, $opt_arg)
PL_V_eq($string, $opt_arg)
PL_ADJ_eq($string, $opt_arg)
classical($string, $opt_arg)
def_noun($string, $opt_arg)
def_verb($string, $opt_arg)
def_adj($string, $opt_arg)
def_a($string, $opt_arg)
def_an($string, $opt_arg)

INTERNAL METHODS

tt_inflect($string, $opt_arg) The underlying inflect filter.

TODO

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.

SEE ALSO

Lingua::EN::Inflect, Template, Template::Plugin

DEDICATION

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/>

AUTHOR



  Original Author:    Andrew Ford               2005-2014
  Current Maintainer: Barbie <barbie@cpan.org>  2014



ACKNOWLEDGEMENTS

Andrew Ford wrote the original plugin code (basing it heavily on the Template::Plugin::Autoformat code).

Damian Conway <damian@conway.org> wrote the Lingua::EN::Inflect module, which does all the clever stuff.

COPYRIGHT & LICENSE

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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 TEMPLATE::PLUGIN::LINGUA::EN::INFLECT (3) 2015-01-01

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.