|
NAMELingua::EN::Infinitive - Determine the infinitive form of a conjugated wordSynopsisuse Lingua::EN::Infinitive; my($spell) = Lingua::EN::Infinitive -> new(); my($word) = 'rove'; # Method 1: my($word1, $word2, $suffix, $rule) = $spell -> stem($word); # Method 2: $spell -> stem($word); my($word1, $word2, $suffix, $rule) = ( $spell -> word1, # A possibility. $spell -> word2, # A possibility, or ''. $spell -> suffix, $spell -> rule, ); print "Conjugated: $word. Infinitive: $word1. \n"; # Now, adjective to noun conversion. my($noun); for (qw/Turkish amateurish cuttlefish vixenish whitish/) { $noun = $spell -> adjective2noun($_); print "$_ => ", (defined $noun ? $noun : $_), ". \n"; } # Now, adjective to noun conversion. my(%expected) = ( Turkish => 'Turkey', amateurish => 'amateur', cuttlefish => '', # I.e. No change because 'cuttlef' can't be an adjective. demolish => '', # Ditto. radish => '', # Ditto. swish => '', # Ditto. vixenish => 'vixen', whitish => 'white', ); my($noun); for (qw/Turkish amateurish cuttlefish demolish radish swish vixenish whitish/) { $noun = $spell -> adjective2noun($_); print "$_ => ", ($noun ? $noun : $_), '. OK: ', ( ($noun eq $expected{$_}) ? 'Yes' : 'No'), ". \n"; } See scripts/demo.pl and t/test.t for sample code. DescriptionGeneric CodeThis section discusses the results from calling the method "stem($word)".Determines the infinitive form of a conjugated word. Also, determines the suffix used to identify which rule to apply to transform the conjugated word into the infinitive form. Either 1 or 2 possible infinitives are returned. You must check that the first is really an English word. If it is, then it is the result. If it is not valid, then check the second. This module does not provide a way of determining whether or not a candidate solution is in fact an English word. Failure to deconjugate is indicated by $word1 eq ''. In general, you can ignore the 3rd and 4th values returned from "stem($word)". The algorithm is based on the McIlroy article (see below), after first checking for irregular words. In the hash 'suffix2rule', you will see the key 'order'. This specifies the sort order in which to check the McIlroy rules. I have changed his ordering in a number of places, based on my interpreation of which order produces the better result. Adjectival CodeThis section discusses the results from calling the method "adjective2noun()".The source contains a list of (adjective => noun) pairs taken from /usr/share/dict/words, and so it can be used to convert adjectives to nouns. I suggest calling "adjective2noun()" if "stem($word)" does not provide a suitable candidate. InstallationYou install "Lingua::EN::Infinitive", as you would install any perl module library, by running these commands:perl Makefile.PL make make test make install WarningDo not make the false assumption that"$word1$suffix" eq $word or "$word2$suffix" eq $word Methodsadjective2noun($adjective)Returns either the noun which was used to generate the adjective in the first place, or the empty string.There are 99 (adjective => noun) pairs in the source code. rule()Must only be called after calling "stem($word)".Returns the same string as the 4th value returned by "stem($word)". stem($word)Returns a 4-element array:
suffix()Must only be called after calling "stem($word)".Returns the same string as the 3rd value returned by "stem($word)". word1()Must only be called after calling "stem($word)".Returns the same string as the 1st value returned by "stem($word)". word2()Must only be called after calling "stem($word)".Returns the same string as the 2nd value returned by "stem($word)". ReferenceTitle: Development of a Spelling List Author: M. Douglas McIlroy Journal: IEEE Transactions on Communications Issue: Vol COM-30, No 1, January 1982 Machine-Readable Change LogThe file Changes was converted into Changelog.ini by Module::Metadata::Changes.Version NumbersVersion numbers < 1.00 represent development versions. From 1.00 up, they are production versions.Repository<https://github.com/ronsavage/Lingua-EN-Infinitive>SupportEmail the author, or log a bug on RT:<https://rt.cpan.org/Public/Dist/Display.html?Name=Lingua::EN::Infinitive>. Author"Lingua::EN::Infinitive" was written by Ron Savage <ron@savage.net.au> in 1998.LicenseAustralian copyright (c) 1999-2002 Ron Savage.All Programs of mine are 'OSI Certified Open Source Software'; you can redistribute them and/or modify them under the terms of The Perl License, a copy of which is available at: http://www.opensource.org/licenses/index.html
Visit the GSP FreeBSD Man Page Interface. |