Jesse S. Bangs

NAME

Lingua::Phonology::Functions

SYNOPSIS

        use Lingua::Phonology;
        use Lingua::Phonology::Functions qw/:all/;

DESCRIPTION

Lingua::Phonology::Functions contains a suite of functions that can be exported to make it easier to write linguistic rules. I hope to have a function here for each broad, sufficiently common linguistic process. So if there are any missing here that you think should be included, feel free to contact the author.

FUNCTIONS

Lingua::Phonology::Functions does not provide an object-oriented interface to its functions. You may either call them with their package name (Lingua::Phonology::Functions::assimilate()), or you may import the functions you wish to use by providing their names as arguments to use. You may import all functions with the argument ':all' (as per the Exporter standard).

        Lingua::Phonology::Functions::assimilate();        # If you haven't imported anything
        use Lingua::Phonology::Functions qw(assimilate);   # Import just assimilate()
        use Lingua::Phonology::Functions qw(:all);          # Import all functions

I have tried to keep the order of arguments consistent between all of the functions. In general, the following hold:

  • If a feature name is needed for a function, that is the first argument.

  • If more than one segment is given as an argument to a function, the first segment will act upon the second segment. That is, some feature from the first segment will be assimilated, copied, dissimilated, etc. to the second segment.

Through these function descriptions, $feature is the name of some feature in the current Lingua::Phonology::Features object, and $segment1, $segment2 . . . $segmentN are Lingua::Phonology::Segment objects depending on that same Features object.

assimilate

        assimilate($feature, $segment1, $segment2);

Assimilates $segment2 to $segment1 on $feature. This does a recursive assimilation, so that all children of $feature are also assimilated. This also does a "deep" assimilation, copying the reference from $segment1 to $segment2 so that future modifications of this feature for either segment will be reflected on both segments. If you don't want this, use copy() instead.

The new value of the feature is returned.

adjoin

        adjoin($feature, $segment1, $segment2);

This function is synonymous with assimilate(). It is provided only to aid readability.

copy

        copy($feature, $segment1, $segment2);

Copies the value of $feature from $segment1 to $segment2, recursively so that all children of $feature are also copied. This does a "shallow" copy, copying the value but not the underlying reference, so that $segment1 and $segment2 can vary independently after the feature value is copied. Returns the new value of the feature.

flat_assimilate

        flat_assimilate($feature, $segment1, $segment2);

Assimilates the value of $feature from $segment1 to $segment2 non-recursively. This will cause the values for $feature to be references to the same value for both segments, but will not affect any of children of $feature for either segment.

flat_adjoin

        flat_adjoin($feature, $segment1, $segment2);

Identical to flat_assimilate. Provided only for readability.

flat_copy

        flat_copy($feature, $segment1, $segment2);

Copies the value of $feature from $segment1 to $segment2 non-recursively. This will cause the numerical value of $feature to be the same for both segments, but will not make them have references to the same data, nor will it affect the children of $feature.

dissimilate

        dissimilate($feature, $segment1, $segment2);

Dissimilates $segment2 from $segment1 on $feature, or something like it. If $segment1->value($feature) is true, then this attempts to assign 1 to $segment2->$feature. If $segment1->value($feature) is false, this attempts to assign 0. The actual value that is subsequently returned will depend on the type of $feature. The new value of $segment2->$feature will be returned.

If $segment1 and $segment2 currently have a reference to the same value for $feature, $segment2 will be assigned a new reference, breaking the connection between the two segments.

change

        change($segment1, $symbol);

This function changes $segment1 to $symbol, where $symbol is a text string indicating a symbol in the symbol set associated with $segment1. If $segment1 doesn't have a symbol set associated with it, this function will fail.

metathesize

        metathesize($segment1, $segment2);

This function swaps the order of $segment1 and $segment2. Returns true on success, false on failure.

$segment1 MUST be the first of the two segments, or else this function may result in a non-terminating loop as the same two segments are swapped repeatedly. (The exact behavior of this depends on the implementation of Lingua::Phonology::Rules, which is not a fixed quantity. But things should be okay if you heed this warning.)

The assumption here is that $segment1 and $segment2 are adjacent segments in some word currently being processed by Lingua::Phonology::Rules, since the notion of "segment order" has little meaning outside of this context. Thus, this function assumes that the INSERT_RIGHT() and INSERT_LEFT() methods are available (which is only true during a Lingua::Phonology::Rules evaluation), and will raise errors if this isn't so.

Note that the segments won't actually be switched until after the current do code reference closes, so you can't make changes to the metathesized segments immediately after changing them and have the segments be where you expect them.

metathesize_feature

        metathesize_feature($feature, $segment1, $segment2);

This function swaps the value of $feature for $segment1 with the value of $feature for $segment2, and returns the new value of $segment2->$feature.

delete_seg

        delete_seg($segment1);

Deletes $segment1. This is essentially a synonym for calling $segment1->clear.

insert_after

        insert_after($segment1, $segment2);

This function inserts $segment2 after $segment1 in the current word. Like "metathesize", this function assumes that it is being called as part of the do property of a Lingua::Phonology::Rules rule, so any environment other than this will probably raise errors.

insert_before

        insert_before($segment1, $segment2);

This function inserts $segment2 before $segment1, just like insert_after(). The same warnings that apply to insert_after() apply to this function.

SEE ALSO

Lingua::Phonology, Lingua::Phonology::Rules, Lingua::Phonology::Features, Lingua::Phonology::Segment

AUTHOR

Jesse S. Bangs <jaspax@cpan.org>.

LICENSE

This module is free software. You can distribute and/or modify it under the same terms as Perl itself.