Lingua::Phonology::Segment 0.32 review
DownloadLingua::Phonology::Segment is a module to represent a segment as a bundle of feature values. SYNOPSIS use Lingua::Phono
|
|
Lingua::Phonology::Segment is a module to represent a segment as a bundle of feature values.
SYNOPSIS
use Lingua::Phonology;
$phono = new Lingua::Phonology;
# Define a feature set
$features = $phono->features;
$features->loadfile;
# Make a segment
$segment = $phono->segment;
# Set some values
$segment->labial(1);
$segment->continuant(0);
$segment->voice(1);
# Segment is now voiced labial stop, i.e. [b]
# Reset the segment
$segment->clear;
A Lingua::Phonology::Segment object provides a programmatic representation of a linguistic segment. Such a segment is associated with a Lingua::Phonology::Features object that lists the available features and the relationships between them. The segment itself is a list of the values for those features.
This module provides methods for returning and setting these feature values. A segment may also be associated with a Lingua::Phonology::Symbols object, which allows the segment to return the symbol that it best matches.
OVERLOADING
As of Lingua::Phonology v0.32 (Lingua::Phonology::Segment v0.4), string conversion of segments is overloaded. When you use a Lingua::Phonology::Segment in string context, the spell() method is automatically called, and the representation of the segment from the current symbolset is returned. String comparison operators (cmp eq ne lt le gt ge) are also overloaded. Therefore, the following work correctly, assuming that you have a Lingua::Phonology object correctly set up in $phono.
my ($b, $k) = $phono->symbols->segment('b', 'k');
print "Segments: $b, $kn"; # Prints "Segments: b, k";
print "$b is greater than $kn" if $b gt $k; # Won't print
print "$b is less than $kn" if $b lt $k; # Prints 'b is less than k';
print "$b is equal to $kn" if $b eq $k; # Won't print
my $b2 = $b->duplicate;
print "$b is equal to $b2n" if $b eq $b2 # Prints 'b is equal to b';
Note that stringification is not overloaded if the symbolset is not properly set. However, it turns on as soon as a symbolset is available:
my $b = Lingua::Phonology::Segment->new($features);
$b->voice(1);
$b->labial(1);
print "$bn"; # Prints 'Lingua::Phonology::Segment=HASH(0x88af598)'
# or something similar, because there is no symbolset
# defined for spelling the segment.
$b->symbolset($symbols);
print "$bn"; # Prints 'b'
Number conversion is not overloaded.
Requirements:
Perl
Lingua::Phonology::Segment 0.32 keywords