perl-i18n

new util method proposition for Maketext

2002-08-31 15:21:42
The following method, loosely adapted from quant(), allows to deal with 
article variation in front of substantives beginning with a,e,i,o,u,y letters 
('voyelles' in french), a phenomenon called 'elision', such as le/l' in 
french. In english there also the a/an case. Maybe it would be useful for 
inclusion in Maketext ?

Note that user has to provide separation space if needed, in order to deal 
with 'apostrophe' case where it is not used:
le bateau -> article is "le "
l'avion -> article is "l'"

sub article {
    my ($self, $subst, @forms) = @_;

    return $subst unless @forms;

    if (@forms == 1) {
        return $forms[0] . $subst;
    } else {
        return $subst =~ /^[aeiouy]/i ?  $forms[1] . $subst : $forms[0] . 
$subst;
    }
        
}

BTW, this is a case where nested [ ] construct would be useful. In french, the 
article has different forms depending of substantive genera:
"le" for a male substantive
"la" for a female substantive
In german also (der/die/das), but as 'elision' doesn't exist, it isn't 
relevant for my demonstration :-)
Let's imagine we have a article_genera method, returning correct form for the 
article given different forms and genera, call to previous method could 
easily be wrotten using nested [ ] this way:
[article,_1,[article_genera,"le ","la ",_2],"l'"]

Is this a correct real-life argument :-) ?
-- 
Guillaume Rousse <rousse(_at_)ccr(_dot_)jussieu(_dot_)fr>
GPG key http://lis.snv.jussieu.fr/~rousse/gpgkey.html


<Prev in Thread] Current Thread [Next in Thread>
  • new util method proposition for Maketext, Guillaume Rousse <=