Path: | lib/linguistics/en.rb |
Last Update: | Tue Dec 06 20:00:33 +0000 2011 |
This module contains English-language linguistic functions for the Linguistics module. It can be either loaded directly, or by passing some variant of ‘en’ or ‘eng’ to the Linguistics::use method.
The functions contained by the module provide:
Plural forms of all nouns, most verbs, and some adjectives are provided. Where appropriate, "classical" variants (for example: "brother" -> "brethren", "dogma" -> "dogmata", etc.) are also provided.
These can be accessed via the #plural, #plural_noun, #plural_verb, and #plural_adjective methods.
Pronunciation-based "a"/"an" selection is provided for all English words, and most initialisms.
See: #a, #an, and #no.
Conversion from Numeric values to words are supported using the American "thousands" system. E.g., 2561 => "two thousand, five hundred and sixty-one".
See the #numwords method.
It is also possible to inflect numerals (1,2,3) and number words ("one", "two", "three") to ordinals (1st, 2nd, 3rd) and ordinates ("first", "second", "third").
This module also supports the creation of English conjunctions from Arrays of Strings or objects which respond to the #to_s message. Eg.,
%w{cow pig chicken cow dog cow duck duck moose}.en.conjunction ==> "three cows, two ducks, a pig, a chicken, a dog, and a moose"
Returns the infinitive form of English verbs:
"dodging".en.infinitive ==> "dodge"
The inflection functions of this module were adapted from Damien Conway‘s Lingua::EN::Inflect Perl module:
Copyright (c) 1997-2000, Damian Conway. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
The conjunctions code was adapted from the Lingua::Conjunction Perl module written by Robert Rothenberg and Damian Conway, which has no copyright statement included.
Copyright (c) 2003-2008, Michael Granger All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author/s, nor the names of the project's contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.