[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lojban] Re: Regular expression for brivla?



> Is there a known regular expression that covers all classes of
> brivla?
>
> What about one that's just really close?
>
> Perl extensions are fine.

Some code I've used in the past.  Note that a lot of it depends on what your
goal is.  The code that follows doesn't have as its goal to be definitive.
Rather, it was part of a program to perform various lookups, and first I needed
to know whether I was searching for rafsi, cmavo, or what.

$C = qr/[bcdfgjklmnprstvxz]/;
$V = qr/[aeiou]/;

#consonant pairs
$CC = qr/(?:
    bd|bl|br|
    cf|ck|cl|cm|cn|cp|cr|ct|
    dj|dr|dz|
    fl|fr|
    gl|gr|
    jb|jd|jg|jm|jv|
    kl|kr|
    ml|mr|
    pl|pr|
    sf|sk|sl|sm|sn|sp|sr|st|
    tc|tr|ts|
    vl|vr|xl|xr|zb|zd|zg|zm|zv
)/x;

#dipthongs
$VV = qr/(?:ai|ei|oi|au)/;

$rafsi3v = qr/(?:$CC$V|$C$VV|$C$V'$V)/;
$rafsi3 = qr/(?:$rafsi3v|$C$V$C)/;
$rafsi4 = qr/(?:$C$V$C$C|$CC$V$C)/;
$rafsi5 = qr/$rafsi4$V/;

$cmavo = qr/(?:$V|$VV|$C$V|$C$VV|$C$V'$V)/;

INPUT: for (@ARGV){
    s/h/'/;

    if (/$C$/){
        print "cmene";
    } elsif (/$CC/){
        if (/^.{0,4}$CC/){
            print "brivla";
        } else {
            print "invalid";
        }
    } else {
        print "cmavo cluster";
    }
}
-- 
Adam Lopresto
http://cec.wustl.edu/~adam/

"Linux means never having to delete your love mail." -- Don Marti