Phonology/Symbols.pm

filter: Statementstmt 89.1% 221 / 248 Branchbran 74.5% 79 / 106 Conditioncond 55.5% 5 / 9 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 31 / 31 Podpod 85.7% 12 / 14 totaltotal 84.5% 350 / 414 CC 75 SCAR 23.3
CC
75
Cov
84%
old_loadfile
45.8
score_diacrit
19.0
score
14.0
CRAP 10.2
« Phonology/Segment/Tier.pm ↑ Summary Phonology/Segment.pm »
1 #!/usr/bin/perl -w
2  
3 package Lingua::Phonology::Symbols;
4  
5 =head1 NAME
6  
7 Lingua::Phonology::Symbols - a module for associating symbols with
8 segment prototypes.
9  
10 =head1 SYNOPSIS
11  
12 use Lingua::Phonology;
13 $phono = new Lingua::Phonology;
14  
15 # Load the default features
16 $phono->features->loadfile;
17  
18 # Load the default symbols
19 $symbols = $phono->symbols;
20 $symbols->loadfile;
21  
22 # Make a test segment
23 $segment = $phono->segment;
24 $segment->labial(1);
25 $segment->voice(1);
26  
27 # Find the symbol matching the segment
28 print $symbols->spell($segment); # Should print 'b'
29  
30 =head1 DESCRIPTION
31  
32 When using Lingua::Phonology, you usually manipulate Segment objects that have
33 various feature values that specify the phonetic qualities of the segment.
34 However, it is difficult to print those feature values, and a list of feature
35 values can be difficult to interpret anyway. This is where Symbols comes in--it
36 provides a way to take a Segment object and get a phonetic symbol representing
37 the properties of that segment.
38  
39 In Symbols, you may use L<add_symbol>() to define text symbols that correlate to
40 "prototypes", which are special Segment objects that represent the ideal
41 segment for each symbol. After you have defined your symbols and prototypes,
42 you may use L<spell>() to find which prototype is the most similar to a segment
43 in question, and get the symbol for that prototype.
44  
45 As of v0.2, Symbols also includes diacritics. A diacritic is a special symbol
46 that begins or ends with a '*', and which is used to modify other symbols. If
47 the best symbol match for a segment you are trying to spell is an imperfect
48 match, Symbols will then attempt to use diacritics to indicate exactly how the
49 segment is pronounced. For compatibility reasons, however, this feature is off
50 by default. It can be turned on with L<set_diacritics>.
51  
52 You will probably want to read the L<add_symbol>, L<spell>, and L<loadfile>
53 sections, because these describe the most widely-used functions and the
54 algorithm used to score potential matches. If you're not getting the results
55 you expect, you probably need to examine the way your prototype definitions are
56 interacting with that algorithm.
57  
58 =cut
59  
60 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 9 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 9 ▶use Lingua::Phonology::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 9 ▶use Lingua::Phonology::Segment;
Subroutine BEGIN: called CC=1 SCAR=0.0
66  
67 9 our $VERSION = 0.3;
68  
69 7 ▶sub err ($) { _err($_[0]) if warnings::enabled() };
Subroutine err: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if warnings::enabled() 0 7 7
70  
71 # Make subs for our flags
72 # flags in sub_name => 'hash_key' format
73 9 my %flags = (
74 auto_reindex => 'AUTOINDEX',
75 diacritics => 'USEDCR'
76 );
77 9 ▶while (my ($sub, $key) = each %flags) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %flags) 18 9 27
78 9 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
79 4 ▶ *$sub = sub {
Subroutine __ANON__: called CC=3 SCAR=11.2
80 4 my $self = shift;
81 4 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 2 4
82 2 ▶ if ($_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) { } 2 0 2
83 2 $self->{$key} = 1;
84 }
85 else {
86 0 $self->{$key} = 0;
87 }
88 }
89 4 return $self->{$key};
90 18 };
91 2 ▶ *{'set_' . $sub} = sub { $_[0]->{$key} = 1 };
Subroutine __ANON__: called CC=1 SCAR=0.0
92 3 ▶ *{'no_' . $sub} = sub {$_[0]->{$key} = 0; 1; };
Subroutine __ANON__: called CC=1 SCAR=0.0
93 }
94  
95 19 ▶sub new {
Subroutine new: called CC=3 SCAR=11.5
Pod documented
96 19 my $proto = shift;
97 19 ▶ my $class = ref($proto) || $proto;
Condition66%2/3
ref $proto || $proto
l!l&&r!l&&!r
1180
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table66%2/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
98 19 my $self = {
99 FEATURES => undef, # a Features object
100 SYMBOLS => {}, # the hash of symbol => prototype
101 DIACRITS => {}, # hash of diacritic => prototype
102 USEDCR => 0, # whether or not to use diacritics (off by default)
103 AUTOINDEX => 1, # whether or not to autoindex (on by default)
104 REINDEX => 0, # whether reindexing is currently necessary
105 INDEX => {}, # index of symbols by feature
106 VALINDEX => {}, # index of features by symbol
107 DCRINDEX => [] # index of diacritics by number of keys
108 };
109  
110 19 my $features = shift;
111 19 ▶ unless (_is_features($features)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_is_features($features)) 0 19 19
112 0 carp "No feature set or bad featureset given for new Symbols object";
113 0 return undef;
114 }
115 19 $self->{FEATURES} = $features;
116  
117 19 bless ($self, $class);
118 19 return $self;
119 }
120  
121 # Add a new symbol (why isn't this called add_symbol? Poor planning . . .)
122 674 ▶sub add_symbol {
Subroutine add_symbol: called CC=4 SCAR=13.9
Pod documented
123 674 my $self = shift;
124 674 my %hash = @_;
125 674 my $err = 0;
126  
127 674 SYMBOL: for my $symbol (keys %hash) {
128  
129 677 ▶ $self->_check_symbol($symbol, $hash{$symbol}) or do {
Branch: 1 branch
BranchTrueFalseTotal
$self->_check_symbol($symbol, $hash{$symbol}) or do { $err = 1; next SYMBOL } 675 2 677
130 2 $err = 1;
131 2 next SYMBOL;
132 };
133  
134 # Drop pre-existing symbols
135 675 $self->drop_symbol($symbol);
136  
137 # Add the new symbol
138 675 $self->_add_symbol($symbol, $hash{$symbol});
139  
140 }
141  
142 674 $self->{REINDEX} = 1;
143  
144 674 ▶ return $err ? () : 1;
Branch: 1 branch
BranchTrueFalseTotal
$err ? : 2 672 674
145 }
146  
147 # Make symbol() synonymous with add_symbol()
148 9 *symbol = \&add_symbol;
149  
150 # Private: check that the symbol prototype is okay
151 678 ▶sub _check_symbol {
Subroutine _check_symbol: called CC=3 SCAR=11.0
152 678 my ($self, $symbol, $ref) = @_;
153  
154 678 ▶ unless (_is_seg($ref)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&_is_seg($ref)) 1 677 678
155 1 return err ("Prototype for '$symbol' is not a Lingua::Phonology::Segment");
156 }
157  
158 677 ▶ if ($self->features ne $ref->featureset) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->features ne $ref->featureset) 1 676 677
159 1 return err("Prototype for '$symbol' has wrong feature set");
160 }
161  
162 # Success--spell the proto w/ this symbolset
163 676 $ref->symbolset($self);
164 676 return 1;
165 }
166  
167 # Private: add the symbol to yourself
168 676 ▶sub _add_symbol {
Subroutine _add_symbol: called CC=2 SCAR=6.9
169 676 my ($self, $symbol, $ref) = @_;
170
171 # Diacritics
172 676 ▶ if ($symbol =~ /(^\*\S+)|(\S+\*$)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($symbol =~ /(^\*\S+)|(\S+\*$)/) { } 81 595 676
173 81 $self->{DIACRITS}->{$symbol} = $ref;
174 }
175  
176 # Regular symbols
177 else {
178 595 $self->{SYMBOLS}->{$symbol} = $ref;
179 }
180 }
181  
182 681 ▶sub drop_symbol {
Subroutine drop_symbol: called CC=3 SCAR=11.0
Pod documented
183 681 my $self = shift;
184 681 for (@_) {
185 684 ▶ delete ($self->{SYMBOLS}->{$_}) or delete ($self->{DIACRITS}->{$_});
Branch: 1 branch
BranchTrueFalseTotal
delete $self->{"SYMBOLS"}{$_} or delete $self->{"DIACRITS"}{$_} 8 676 684
186 }
187 681 $self->{REINDEX} = 1;
188 }
189  
190 2 ▶sub change_symbol {
Subroutine change_symbol: called CC=5 SCAR=16.3
Pod documented
191 2 my $self = shift;
192 2 my %hash = @_;
193 2 my $err = 0;
194  
195 2 SYMBOL: for my $symbol (keys(%hash)) {
196 2 ▶ if (not exists $self->{SYMBOLS}->{$symbol}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"SYMBOLS"}{$symbol}) 1 1 2
197 1 err "No symbol $symbol defined";
198 1 $err = 1;
199 1 next SYMBOL;
200 }
201  
202 1 ▶ $self->_check_symbol($symbol, $hash{$symbol}) or do {
Branch: 1 branch
BranchTrueFalseTotal
$self->_check_symbol($symbol, $hash{$symbol}) or do { $err = 1; next SYMBOL } 1 0 1
203 0 $err =1;
204 0 next SYMBOL;
205 };
206  
207 1 $self->_add_symbol($symbol, $hash{$symbol});
208
209 }
210  
211 2 $self->{REINDEX} = 1;
212  
213 2 ▶ return $err ? () : 1;
Branch: 1 branch
BranchTrueFalseTotal
$err ? : 1 1 2
214 }
215  
216 57 ▶sub reindex {
Subroutine reindex: called CC=4 SCAR=13.9
Pod documented
217 57 my $self = shift;
218 57 $self->{REINDEX} = 0;
219 57 $self->{INDEX} = {};
220  
221 # Index symbols by feature => value
222 57 for my $symbol (keys %{$self->{SYMBOLS}}) {
223 3313 my %feat = $self->{SYMBOLS}->{$symbol}->all_values;
224 3313 $self->{VALINDEX}->{$symbol} = \%feat;
225  
226 3313 for (keys %feat) {
227 9 ▶ no warnings 'uninitialized'; # Avoid the warning when $feat{$_} is undef
Subroutine BEGIN: called CC=1 SCAR=0.0
228 13484 push @{$self->{INDEX}->{$_}->{$feat{$_}}}, $symbol;
229 }
230 }
231  
232 # Sort diacritics by number of keys.
233 $self->{DCRINDEX} = [
234 sort
235 {
236 893 my %a = $self->{DIACRITS}->{$a}->all_values;
237 893 my %b = $self->{DIACRITS}->{$b}->all_values;
238 893 return keys(%b) <=> keys(%a);
239 }
240 57 keys %{$self->{DIACRITS}}
241 ];
242  
243 # Also add diacritics to VALINDEX
244 57 for (keys %{$self->{DIACRITS}}) {
245 473 my %feats = $self->{DIACRITS}->{$_}->all_values;
246 473 $self->{VALINDEX}->{$_} = \%feats;
247 }
248  
249 57 return 1;
250 }
251  
252 10 ▶sub loadfile {
Subroutine loadfile: called CC=4 SCAR=13.9
Pod documented
253 10 my ($self, $file) = @_;
254  
255 10 my $parse;
256
257 # Loading default symbols
258 10 ▶ if (not defined $file) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $file) { } 8 2 10
259 8 my $start = tell DATA;
260 8 my $string = join '', <DATA>;
261 8 eval { $parse = _parse_from_string($string, 'symbols') };
262 8 ▶ return err $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 8 8
263 8 seek DATA, $start, 0;
264 }
265  
266 # Loading an actual file
267 else {
268 2 eval { $parse = _parse_from_file($file, 'symbols') };
269 2 ▶ if (!$parse) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($parse) 1 1 2
270 1 return $self->old_loadfile($file);
271 }
272 }
273  
274 9 $self->_load_from_struct($parse);
275 }
276  
277 1 ▶sub old_loadfile {
Subroutine old_loadfile: called CC=8 SCAR=38.2
Pod documented
278 1 my ($self, $file) = @_;
279  
280 1 eval { $file = _to_handle($file, '<') };
281 1 ▶ return err $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 1 0 1
282 0 err "Deprecated method";
283  
284 0 ▶ while (<$file>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $file)) 0 0 0
285 0 s/#.*$//; # Remove comments
286 0 ▶ if (/^\s*(\S*)\t+(.*)/) { # General line format
Branch: 1 branch
BranchTrueFalseTotal
if (/^\s*(\S*)\t+(.*)/) 0 0 0
287 0 my $symbol = $1;
288 0 my @desc = split(/\s+/, $2);
289  
290 0 my $proto = Lingua::Phonology::Segment->new( $self->features );
291 0 for (@desc) {
292 0 ▶ if (/(\S+)=(\S+)/) { # Feature defs like coronal=1
Branch: 2 branches
BranchTrueFalseTotal
if (/(\S+)=(\S+)/) { } 0 0 0
elsif (/([*+-])?(\S+)/) { } 0 0 0
293 0 $proto->value($1, $2);
294 }
295 elsif (/([*+-])?(\S+)/) { # Feature defs like +feature or feature
296 0 ▶ my $val = $1 ? $1 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 0 0 0
297 0 $proto->value($2, $val);
298 }
299 }
300 0 $self->symbol($symbol => $proto);
301 }
302 }
303  
304 0 close $file;
305  
306 0 $self->{REINDEX} = 1;
307 }
308  
309 11 ▶sub _load_from_struct {
Subroutine _load_from_struct: called CC=2 SCAR=6.9
310 11 my ($self, $parse) = @_;
311  
312 11 ▶ while ( my ($sym, $val) = each %$parse ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$parse) 668 11 679
313 my $proto = new Lingua::Phonology::Segment($self->{FEATURES},
314 668 { map { $_ => $val->{feature}->{$_}->{value} } keys %{$val->{feature}} } );
315 668 $self->symbol($sym => $proto);
316 }
317 11 $self->{REINDEX} = 1;
318 }
319  
320 2 ▶sub _to_str {
Subroutine _to_str: called CC=5 SCAR=16.1
321 2 my $self = shift;
322  
323 2 my $href = {};
324 2 for ($self->{SYMBOLS}, $self->{DIACRITS}) {
325 4 for my $sym (keys %$_) {
326 83 my %h = $_->{$sym}->all_values;
327 83 for (keys %h) {
328 294 ▶ $h{$_} = '*' if not defined $h{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $h{$_} 5 289 294
329 294 $href->{$sym}->{feature}->{$_} = { value => $h{$_} };
330 }
331 }
332 }
333  
334 2 return eval { _string_from_struct({ symbols => { symbol => $href } }) };
335 }
336  
337 679 ▶sub spell {
Subroutine spell: called CC=5 SCAR=16.1
Pod documented
338 679 my $self = shift;
339  
340 679 my @return = ();
341 679 for my $comp (@_) {
342 740 ▶ return err("Bad argument to spell()") unless _is_seg($comp);
Branch: 1 branch
BranchTrueFalseTotal
unless &_is_seg($comp) 1 739 740
343 739 my $winner = $self->score($comp);
344 739 ▶ push (@return, $winner ? $winner : '_?_');
Branch: 1 branch
BranchTrueFalseTotal
$winner ? : 702 37 739
345 }
346  
347 678 local $" = '';
348 678 ▶ return wantarray ? @return : "@return";
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 678 678
349 }
350
351 739 ▶sub score {
Subroutine score: called CC=14 SCAR=26.4
Pod documented
352 739 my $self = shift;
353 739 my $comp = shift;
354  
355 # Reindex if necessary
356 739 ▶ $self->reindex if $self->{REINDEX} and $self->{AUTOINDEX};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"REINDEX"} and $self->{"AUTOINDEX"} 56 683 739
Condition100%3/3
$self->{"REINDEX"} and $self->{"AUTOINDEX"}
!ll&&!rl&&r
682156
MC/DC100%2/2
$self->{"REINDEX"} and $self->{"AUTOINDEX"}
$self->{"REINDEX"} $self->{"AUTOINDEX"}
Truth table100%3/3
A and B
A= $self->{"REINDEX"}B= $self->{"AUTOINDEX"}
ABresult
0X0
100
111
357  
358 # Prepare data containers
359 739 my %comp = $comp->all_values;
360 739 my %scores = ();
361 739 my @scores = ();
362  
363  
364 739 for my $feature (keys %{$self->{INDEX}}) {
365 10080 ▶ while (my ($val, $list) = each %{$self->{INDEX}->{$feature}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"INDEX"}{$feature};}) 13260 10080 23340
366 # Avoid all sorts of harmless warnings
367 9 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
368  
369 # Special case: when $val is '' (which is equiv w/ undef), check
370 # that $comp->$feature actually returns undef, in case $feature is
371 # a node w/ defined children
372 13260 ▶ $comp{$feature} = $comp->$feature if $val eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $val eq "" 1258 12002 13260
373  
374 13260 ▶ if ($val eq $comp{$feature}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val eq $comp{$feature}) { } 2963 10297 13260
375 2963 $scores{$_}++ for @$list;
376 }
377 else {
378 10297 $scores{$_}-- for @$list;
379 }
380 }
381 }
382  
383 # Build @scores
384 739 ▶ while (my ($sym, $score) = each %scores) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %scores) 44168 739 44907
385 44168 ▶ $scores[$score] = $sym if $score > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $score > 0 6457 37711 44168
386 }
387  
388 # Get a diacritic spelling if wanted
389 739 ▶ my $sub = @scores ? $#scores : 0;
Branch: 1 branch
BranchTrueFalseTotal
@scores ? : 702 37 739
390 739 ▶ if ($self->{USEDCR}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"USEDCR"}) 6 733 739
391 6 $scores[$sub] = score_diacrit($self, $scores[$sub], %comp);
392 }
393  
394 739 ▶ return wantarray ? %scores : $scores[$sub];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 739 739
395 }
396  
397 6 ▶sub score_diacrit {
Subroutine score_diacrit: called CC=15 SCAR=29.4
Pod undocumented
398 6 my ($self, $symbol, %comp) = @_;
399  
400 # Don't try to diacriticize completely unmatched segments
401 6 ▶ return '' if not $symbol;
Branch: 1 branch
BranchTrueFalseTotal
unless $symbol 1 5 6
402  
403 # Avoid warnings
404 9 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
405  
406 # Build hash of discrepancy
407 5 my %disc = ();
408 5 for (keys %comp) {
409 13 ▶ $disc{$_} = $comp{$_} if $comp{$_} ne $self->{VALINDEX}->{$symbol}->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $comp{$_} ne $self->{"VALINDEX"}{$symbol}{$_} 1 12 13
410 }
411 5 for (keys %{$self->{VALINDEX}->{$symbol}}) {
412 12 ▶ $disc{$_} = $comp{$_} if $comp{$_} ne $self->{VALINDEX}->{$symbol}->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $comp{$_} ne $self->{"VALINDEX"}{$symbol}{$_} 0 12 12
413 }
414
415 5 DIACRIT: for (@{$self->{DCRINDEX}}) {
416 # Quit if there's no more discrepancy
417 5 ▶ last if not keys %disc;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %disc 4 1 5
418  
419 1 my $dcr = $_; # No aliasing! otherwise s/// messes us up
420  
421 # Diacrits musn't disagree w/ comp segs at all
422 1 my %proto = %{$self->{VALINDEX}->{$dcr}};
423 1 for (keys %proto) {
424 # Defined features compare normally
425 1 ▶ if (defined $proto{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proto{$_}) { } 1 0 1
426 1 ▶ next DIACRIT if ($proto{$_} ne $disc{$_});
Branch: 1 branch
BranchTrueFalseTotal
if $proto{$_} ne $disc{$_} 0 1 1
427 }
428  
429 # Undefined features must be specifically mentioned in the
430 # discrepancy hash (i.e. can't be simply missing keys
431 else {
432 0 ▶ next DIACRIT unless (exists $disc{$_}) and (not defined $disc{$_});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $disc{$_} and not defined $disc{$_} 0 0 0
Condition0%0/3
exists $disc{$_} and not defined $disc{$_}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $disc{$_} and not defined $disc{$_}
exists $disc{$_} not defined $disc{$_}
Truth table0%0/3
A and not(B)
A= exists $disc{$_}B= not defined $disc{$_}
ABresult
0X0
100
111
433 }
434 }
435  
436 # If you get here, you agree on all features, so you should be added
437  
438 # Don't allow anybody else to match your features
439 1 delete $disc{$_} for keys %proto;
440  
441 # Add yourself to the beginning or ending, chopping the leading/trailing '*'
442 1 ▶ if ($dcr =~ s/^\*//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dcr =~ s/^\*//) { } 1 0 1
443 1 $symbol .= $dcr;
444 }
445 else {
446 0 $dcr =~ s/\*$//;
447 0 $symbol = $dcr . $symbol;
448 }
449 }
450  
451 5 return $symbol;
452 }
453  
454 173 ▶sub prototype {
Subroutine prototype: called CC=3 SCAR=11.1
Pod documented
455 173 my $self = shift;
456 173 my $symbol = shift;
457 173 my $proto;
458  
459 173 ▶ if ($symbol =~ /(^\*)|(\*$)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($symbol =~ /(^\*)|(\*$)/) { } 0 173 173
460 0 $proto = $self->{DIACRITS}->{$symbol};
461 }
462 else {
463 173 $proto = $self->{SYMBOLS}->{$symbol};
464 }
465  
466 173 ▶ return err("No such symbol '$symbol'") if (not $proto);
Branch: 1 branch
BranchTrueFalseTotal
unless $proto 2 171 173
467 171 $self->{REINDEX} = 1;
468 171 return $proto;
469 }
470  
471 45 ▶sub segment {
Subroutine segment: called CC=5 SCAR=16.6
Pod documented
472 45 my $self = shift;
473  
474 # If you're not given a symbol, return a blank segment
475 45 ▶ unless (@_) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 0 45 45
476 0 my $ret = Lingua::Phonology::Segment->new( $self->features );
477 0 $ret->symbolset($self);
478 0 return $ret;
479 }
480  
481 # Otherwise
482 45 my @return;
483 45 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 155 44 199
484 155 my $proto = $self->prototype( shift );
485 155 ▶ return unless $proto;
Branch: 1 branch
BranchTrueFalseTotal
unless $proto 1 154 155
486 154 push @return, $proto->duplicate;
487 }
488 44 ▶ return wantarray ? @return : $return[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 42 2 44
489 }
490  
491 680 ▶sub features {
Subroutine features: called CC=3 SCAR=11.0
Pod documented
492 680 my $self = shift;
493 680 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 679 680
494 1 my $arg = shift;
495 1 ▶ return carp "Bad argument to features()" unless _is_features($arg);
Branch: 1 branch
BranchTrueFalseTotal
unless &_is_features($arg) 0 1 1
496 1 $self->{FEATURES} = $arg;
497 }
498 680 return $self->{FEATURES};
499 }
500  
501 9 1;
502  
503 =head1 METHODS
504  
505 =head2 new
506  
507 $symbol = Lingua::Phonology::Symbols->new($features);
508  
509 Creates a new Symbols object. This method takes one argument, a Features
510 object that provides the feature set for the prototypes in this object.
511 This will carp if you don't provide an appropriate object.
512  
513 This method is called automatically when you make a C<new
514 Lingua::Phonology>.
515  
516 =head2 add_symbol
517  
518 $symbol->add_symbol( 'b' => $b );
519  
520 Adds one or more symbols to the current object. The argument to symbol must be
521 a hash. The keys of this hash are the text symbols that will be returned, and
522 the values should be Lingua::Phonology::Segment objects that act as the
523 prototypes for each symbol. See L<"spell"> for explanation of how these symbols
524 and protoypes are used.
525  
526 Symbols can generally be any text string. However, strings beginning or ending
527 with '*' are interpreted specially, as diacritics. The position of the asterisk
528 indicates where the base symbol goes, and the rest is interpreted as the
529 diacritic. Diacritic prototypes are also treated differently from regular
530 prototypes--see the L<spell> section for details. For example, you could use a
531 tilde '~' following a symbol to indicate nasality with the following call to
532 symbol:
533  
534 # Assume $nasal is an appropriate prototye
535 $symbols->add_symbol('*~' => $nasal);
536  
537 Note that '*' by itself is still a valid, non-diacritic symbol. However, '**'
538 will be interpreted as a diacritic consisting of a symbol followed by a single
539 asterisk.
540  
541 If you attempt to pass in a Lingua::Phonology::Segment object associated with a
542 feature set other than the one defined for the current object, C<add_symbol()>
543 will skip to the next symbol and emit a warning.
544  
545 This method returns true if all of the attempted symbol additions succeeded,
546 and false otherwise.
547  
548 =head2 symbol (deprecated)
549  
550 Synonymous with C<add_symbol()>. This method is deprecated, and only exists
551 because of a poor naming choice in earlier versions of the module.
552  
553 =head2 drop_symbol
554  
555 $symbols->drop_symbol('x');
556  
557 Deletes a symbol from the current object. Nothing happens if you try to
558 delete a symbol which doesn't currently exist.
559  
560 =head2 change_symbol
561  
562 $symbols->change_symbol( 'b' => $b );
563  
564 Acts exactly the same as C<add_symbol()>, but first checks to make sure that
565 there already exists a symbol with the key given. Otherwise, it brings
566 up an error.
567  
568 The method C<add_symbol()> can also be used to redefine existing symbols, but
569 it first drops any existing symbol. In the present implementation this makes no
570 difference, so this method really only exists to aid readability and allow for
571 future expansion.
572  
573 As with C<add_symbol()>, this method returns true if all of the attempted
574 changes succeeded, otherwise false.
575  
576 =head2 features
577  
578 $features = $symbols->features();
579  
580 Returns the Features object associated with the current object, or sets the
581 object if provided with a Lingua::Phonology::Features object as an argument.
582  
583 =head2 prototype
584  
585 $proto = $symbols->prototype('b');
586  
587 Takes one argument, a text string indicating a symbol in the current set.
588 Returns the prototype associated with that symbol, or carps if no
589 such symbol is defined. You can then make changes to the prototype object,
590 which will be reflected in subsequent calls to spell().
591  
592 =head2 segment
593  
594 # Get one segment
595 $b = $symbols->segment('b');
596
597 # Get several segments
598 @word = $symbols->segment('b', 'a', 'n');
599  
600 Takes one or more argument, a symbol, and return a new Segment object with the
601 feature values of the prototype for that symbol. Unlike L<prototype>, which
602 return the prototype itself, this method returns a completely new object which
603 can be modified without affecting the values of the prototype. If you supply a
604 list of symbols, you'll get back a list of segments in the same order. This is
605 generally the easiest way to make new segments with some features already set.
606 Example:
607  
608 The segments returned from this method will be associated with the
609 Lingua::Phonology::Features object defined by C<features()> and the current
610 Lingua::Phonology::Symbols object.
611  
612 =head2 reindex
613  
614 $symbols->reindex();
615  
616 This function recompiles the internal index that Lingua::Phonology::Symbols
617 uses to speed up C<spell>ing. It should generally be unnecessary to call this
618 function, as Lingua::Phonology::Symbols does its best to figure out when
619 reindexing is necessary without any user input. You may call this function by
620 hand to ensure reindexing at a particular time, or if auto reindexing is off.
621  
622 =head2 auto_reindex
623  
624 # Get the current state of auto-reindexing
625 $auto_reindex = $symbols->auto_reindex();
626  
627 # Set the auto-reindexing flag
628 $symbols->auto_reindex(0);
629  
630 Returns true if automatic reindexing is currently turned on, false otherwise.
631 If called with an argument, sets auto reindexing to the truth or falsehood of
632 that argument. Auto reindexing is on by default.
633  
634 =head2 set_auto_reindex
635  
636 $symbols->set_auto_reindex();
637  
638 Turns automatic reindexing (back) on. Same as C<auto_reindex(1)>. Auto
639 reindexing is on by default, so this is only necessary after a call to
640 C<no_auto_reindex>. See L<"INDEXING">.
641  
642 =head2 no_auto_reindex
643  
644 $symbols->no_auto_reindex();
645  
646 Turns automatic reindexing off. Same as C<< auto_reindex(0) >>. See
647 L<"INDEXING">.
648  
649 =head2 diacritics
650  
651 # Get the current diacritic flag
652 $symbols->diacritics();
653  
654 # Set the diacritics flag
655 $symbols->diacritics(1);
656  
657 Returns true if diacritics are currently on, otherwise false. You may also pass
658 this method an argument to turn diacritics on or off, e.g. C<<
659 $symbols->diacritics(1) >>. Diacritics are off by default.
660  
661 =head2 set_diacritics
662  
663 $symbols->set_diacritics();
664  
665 Turns diacritics on. Same as C<< diacritics(1) >>.
666  
667 =head2 no_diacritics
668  
669 $symbols->no_diacritics();
670  
671 Turns diacritics off. Same as C<< diacritics(0) >>.
672  
673 =head2 spell
674  
675 print $symbols->spell($seg);
676  
677 Takes any number of Lingua::Phonology::Segment objects as arguments. For each
678 object, returns a text string indicating the best match of prototype with the
679 Segment given. In a scalar context, returns a string consisting of a
680 concatencation of all of the symbols.
681  
682 The Symbol object given will be compared against every prototype currently
683 defined, and scored according to the following algorithm:
684  
685 =over 4
686  
687 =item *
688  
689 Score one point for every feature whose value is the same for both the
690 prototype and the comparison segments, whether that value is defined or not.
691  
692 =item *
693  
694 Lose one point for every feature that is defined for the prototype segment and
695 which the comparison segment disagrees with.
696  
697 =item *
698  
699 Score zero points for each feature defined on the comparison segment but not
700 defined for the prototype.
701  
702 =back
703  
704 Comparison segments may always be more defined than the prototypes, so
705 there is no consequence if the comparison segment is defined for features
706 that the prototype isn't defined for.
707  
708 Note that this algorithm is slightly different from the one used in previous
709 versions. In my informal tests, about 95% of the segments come out the same,
710 but there is some discrepancy. My subjective impression is that the results
711 given by the new algorithm are better (more inuitive) than those from the
712 previous algorithm.
713  
714 The 'winning' prototype is the one that scores the highest by the preceding
715 algorithm. If more than one prototype scores the same, it's unpredictable which
716 symbol will be returned, since it will depend on the order in which the
717 prototypes came out of the internal hash.
718  
719 If C<diacritics> is on, diacritic formation happens after the best-matching
720 symbol is chosen. A list of the features for which the comparison segment and
721 symbol prototypes do not agree is compiled, and diacritics are selected that
722 match against those features. If there are diacritics that specify more than
723 one feature, or multiple diacritics specifying the same feature, then this
724 method will attempt to minimize the number of diacritics used. The diacritic
725 symbols will be concatenated with the base symbol, the base symbol taking the
726 place of the asterisk in the symbol definition. For example, if a segment
727 matched the base symbol 'a' and the diacritic '*~', the resulting symbol would
728 be 'a~'. If multiple diacritics are matched, there is no way to predict the
729 order in which they will be added, except that diacritics specifying multiple
730 features will appear closer to the base.
731  
732 If no prototype scores at least 1 point by this algorithm, the string '_?_'
733 will be returned. This indicates that no suitable matches were found. No
734 diacritic matching is done in this case.
735  
736 Beware of testing a Segment object that is associated with a different feature
737 set than the ones used by the prototypes. This will almost certainly cause
738 errors and bizarre results.
739  
740 =head2 score
741  
742 %score = $symbols->score($seg);
743  
744 Takes a Segment argument and compares it against the defined symbols, just like
745 symbol(). It normally returns a hash with the available symbols as the keys and
746 the score for each symbol as the value. In a scalar context, returns the
747 winning symbol just like spell(). Useful for debugging and determining why the
748 program thinks that [a] is better described as [d] (as happened to the author
749 during testing). Unfortunately, score() can only be used to test one segment at
750 a time, rather than a list of segments.
751  
752 =head2 loadfile
753  
754 # Load symbol definitions from a file
755 $symbols->loadfile('phono.xml');
756  
757 # Load default symbols
758 $symbols->loadfile();
759  
760 Takes one argument, a file name, and loads prototype segment definitions
761 from that file. If no file name is given, loads the default symbol set.
762  
763 Files should be in the XML format described in
764 L<Lingua::Phonology::FileFormatPOD>. If the filename given does not parse
765 correctly, this method will fall back on C<old_loadfile()>, just in case this
766 is an old script using the deprecated custom file format. In this case, you
767 will get a warning. To avoid the warning, change the method call, or better yet
768 change your file over to the XML format.
769  
770 =head2 old_loadfile (deprecated)
771  
772 # Load a file
773 $symbols->old_loadfile('symbols.txt');
774  
775 This method is deprecated. Use C<loadfile()> instead.
776  
777 Takes one argument, a file name. Reads that file according to the format
778 described below and adds the symbols defined there to the current symbols
779 object. This method does NOT load default features when called without any
780 arguments.
781  
782 Lines in the file should match the regular expression /^\s*(\S+)\t+(.*)/.
783 The first parenthesized sub-expression will be taken as the symbol, and the
784 second sub-expression as the feature definitions for the prototype. Feature
785 definitions are separated by spaces, and should be in one of three formats:
786  
787 =over 4
788  
789 =item *
790  
791 B<feature>: The preferred way to set a privative value is simply to write the
792 name of the feature unadorned. Since privatives are either true or undef, this
793 is sufficient to declare the existence of a privative. E.g., since both
794 [labial] and [voice] are privatives in the default feature set, the following
795 line suffices to define the symbol 'b' (though you may want more specificity):
796  
797 b labial voice
798  
799 =item *
800  
801 B<[+-*]feature>: The characters before the feature correspond to setting the
802 value to true, false, and undef, respectively. This is the preferred way to set
803 binary features, and the only way to assert that a feature of any type must be
804 undef. For example, the symbol 'd`' for a voiced retroflex stop can be defined
805 with the following line:
806  
807 d` -anterior -distributed voice
808  
809 =item *
810  
811 B<feature=value>: Whatever precedes the equals sign is the feature name;
812 whatever follows is the value. This is the preferred way to set scalar values,
813 and the only way to set scalar values to anything other than undef, 0, or 1.
814  
815 =back
816  
817 Feature definitions may work if you use them other than as recommended,
818 but the recommended forms are provided for maximum readability. To be
819 exact, however, the following are synonymous:
820  
821 # Synonymous one way
822 labial
823 +labial
824 labial=1
825  
826 # Synonymous in a different way
827 -labial # only if 'labial' is binary
828 labial=0
829  
830 Since this behavior is partly dependent on the implementation of text and
831 number forms in the Features module, the synonymity of these forms is not
832 guaranteed to remain constant in the future. However, every effort will be
833 made the guarantee that the I<recommended> forms won't change their
834 behavior.
835  
836 You may begin comments with '#'--anything between the first '#' on a line and
837 the end of that line will be ignored. Consequently, '#' cannot be used as a
838 symbol in a loaded file (though it is a valid symbol elsewhere, and can be
839 assigned via C<add_symbol()>).
840  
841 As with C<add_symbol()>, symbol definitions beginning or ending with '*' will be
842 interpreted as diacritics. Diacritic symbols may be defined in exactly the same
843 way as regular symbols. Thus, to define a tilde as a diacritic for nasality,
844 you might use the following simple line:
845  
846 *~ nasal
847  
848 You should only define terminal (non-node) features in your segment
849 definitions. The loadfile method is unable to deal with features that
850 are nodes, and will generate errors if you try to assign to a node.
851  
852 If you don't give a file name, then the default symbol set is loaded. This
853 is described in L<"THE DEFAULT SYMBOL SET">.
854  
855 =head1 INDEXING
856  
857 This section endeavors to explain the purpose of indexing in
858 Lingua::Phonology::Symbols, and how you can control it.
859  
860 As of v0.2, this module uses an efficient hash comparison algorithm that
861 greatly speeds up calls to C<spell> and C<score>. This algorithm works by
862 compiling an index of the features and values that prototype segments have,
863 then only comparing against those prototypes that have some chance of winning.
864 Indexing itself is a somewhat costly procedure, but fortunately, it only needs
865 to be done once. Unfortunately, it needs to be done again any time that the
866 list of symbols or the prototypes for those symbols is changed.
867  
868 Fortunately again, Lingua::Phonology::Symbols will take care of this for you.
869 Whenever a method is called that might require reindexing, an internal flag on
870 the object is set. The next time that you ask this module to C<spell>
871 something, it will first reindex, then proceed to spelling. The methods that
872 will trigger reindexing are C<add_symbol, drop_symbol, change_symbol, loadfile,
873 prototype>. This reindexing is done "just in time", and isn't done more than is
874 necessary.
875  
876 Unfortunately, not all calls to those methods actually warrant reindexing, so
877 if you call those methods a lot, you might want to have manual control over
878 when the hash is reindexed. To do this, you can use the method
879 C<no_auto_reindex>, which will disable automatic reindexing. You then will have
880 to call C<reindex> yourself whenever it's warranted. If you get tired of this
881 and want reindexing back, you can call C<set_auto_reindex>.
882  
883 The author of this module has never felt the need to work with auto reindexing
884 off, for what it's worth.
885  
886 =head1 THE DEFAULT SYMBOL SET
887  
888 Currently, Lingua::Phonology::Symbols comes with a set of symbols that can
889 be loaded by calling loadfile with no arguments, like so:
890  
891 $symbols->loadfile;
892  
893 The symbol set thus loaded is based on the X-SAMPA system for encoding the IPA
894 into ASCII. You can read more about X-SAMPA at
895 L<http://www.phon.ucl.ac.uk/home/sampa/x-sampa.htm>. The default does not
896 contain all of the symbols in X-SAMPA, but it does contain a lot of them, plus
897 a few extra symbols for IPA characters not covered in X-SAMPA. These symbols are:
898  
899 # Consonants
900 # Labials
901 p voiceless labial stop
902 b voiced labial stop
903 f voiceless labiodental fricative
904 v voiced labiodental fricative
905 m labial nasal
906  
907 # Dentals
908 t voiceless dental stop
909 d voiced dental stop
910 T voiceless dental fricative
911 D voiced dental fricative
912 s voiceless alveolar fricative
913 z voiced alveolar fricative
914 n alveolar nasal
915 l alveolar lateral
916 r alveolar rhotic
917  
918 # Postalveolars
919 tS voiceless postalveolar stop
920 dZ voiced postalveolar stop
921 S voiceless postalveolar fricative
922 Z voiced postalveolar fricative
923  
924 # Retroflex
925 t` voiceless retroflex stop
926 d` voiced retroflex stop
927 s` voiceless retroflex fricative
928 z` voiced retroflex fricative
929 n` retroflex nasal
930 l` retroflex lateral
931 r` retroflex rhotic
932  
933 # Palatal
934 c voiceless palatal stop
935 d\ voiced palatal stop
936 C voiceless palatal fricative
937 j\ voiced palatal fricative
938 J palatal nasal
939 L palatal lateral
940  
941 # Velar
942 k voiceless velar stop
943 g voiced velar stop
944 x voiceless velar fricative
945 G voiced velar fricative
946 N velar nasal
947  
948 # Uvular
949 q voiceless uvular stop
950 G\ voiced uvular stop
951 X voiceless uvular fricative
952 R voiced uvular fricative
953 N\ uvular nasal
954 R\ uvular rhotic
955  
956 # Pharyngeal
957 q\ voiceless pharyngeal stop
958 X\ voiceless pharyngeal fricative
959 ?\ voiced pharyngeal fricative
960  
961 # Glottal
962 ? voiceless glottal stop
963 h voicelesss glottal fricative
964 h\ voiced glottal fricative
965  
966 # Vowels
967 # High Front Vowels
968 i high front tense
969 I high front
970 y high front rounded tense
971 Y high front rounded
972 j high front semivowels
973 H high front rounded semivowel
974  
975 # High Back Vowels
976 u high back rounded tense
977 U high back rounded
978 M high back unrounded
979 w high back rounded semivowel
980  
981 # High Central Vowels
982 1 high central
983 } high central rounded
984  
985 # Mid Front Vowels
986 e mid front tense
987 E mid front
988 2 mid front rounded tense
989 9 mid front rounded
990  
991 # Mid Back Vowels
992 o mid back rounded tense
993 O mid back rounded
994 W mid back unrounded tense
995 V mid back unrounded
996  
997 # Mid Central Vowels
998 @ mid central
999 8 mid central rounded
1000  
1001 # Low Vowels
1002 a low
1003 Q low rounded
1004  
1005 # Diacritics
1006 ~ nasal
1007 _l lateral
1008 _v voiced
1009 _0 voiceless
1010 _h aspirated (spread)
1011 _~ creaky voice (constricted)
1012 _w labialized
1013 _d laminalized
1014 _G velarized
1015 _? pharyngealized
1016  
1017 The symbols are defined with the following XML structure, which you can use as
1018 a model if you need to write your own symbols definition:
1019  
1020 <phonology>
1021 <symbols>
1022
1023 <!-- Consonants -->
1024  
1025 <!-- Labials -->
1026 <symbol label="p">
1027 <feature value="0" name="continuant" />
1028 <feature value="1" name="labial" />
1029 </symbol>
1030 <symbol label="b">
1031 <feature value="1" name="voice" />
1032 <feature value="0" name="continuant" />
1033 <feature value="1" name="labial" />
1034 </symbol>
1035 <symbol label="f">
1036 <feature value="1" name="continuant" />
1037 <feature value="1" name="labial" />
1038 </symbol>
1039 <symbol label="v">
1040 <feature value="1" name="voice" />
1041 <feature value="1" name="continuant" />
1042 <feature value="1" name="labial" />
1043 </symbol>
1044 <symbol label="m">
1045 <feature value="1" name="sonorant" />
1046 <feature value="0" name="continuant" />
1047 <feature value="1" name="nasal" />
1048 <feature value="1" name="labial" />
1049 </symbol>
1050  
1051 <!-- Dentals and alveolars -->
1052 <symbol label="t">
1053 <feature value="1" name="anterior" />
1054 <feature value="0" name="continuant" />
1055 </symbol>
1056 <symbol label="d">
1057 <feature value="1" name="voice" />
1058 <feature value="1" name="anterior" />
1059 <feature value="0" name="continuant" />
1060 </symbol>
1061 <symbol label="T">
1062 <feature value="1" name="anterior" />
1063 <feature value="1" name="continuant" />
1064 <feature value="1" name="distributed" />
1065 </symbol>
1066 <symbol label="D">
1067 <feature value="1" name="voice" />
1068 <feature value="1" name="anterior" />
1069 <feature value="1" name="continuant" />
1070 <feature value="1" name="distributed" />
1071 </symbol>
1072 <symbol label="s">
1073 <feature value="1" name="anterior" />
1074 <feature value="1" name="continuant" />
1075 <feature value="0" name="distributed" />
1076 </symbol>
1077 <symbol label="z">
1078 <feature value="1" name="voice" />
1079 <feature value="1" name="anterior" />
1080 <feature value="1" name="continuant" />
1081 <feature value="0" name="distributed" />
1082 </symbol>
1083 <symbol label="n">
1084 <feature value="1" name="sonorant" />
1085 <feature value="1" name="anterior" />
1086 <feature value="0" name="continuant" />
1087 <feature value="1" name="nasal" />
1088 </symbol>
1089 <symbol label="l">
1090 <feature value="1" name="lateral" />
1091 <feature value="1" name="sonorant" />
1092 <feature value="1" name="anterior" />
1093 <feature value="1" name="approximant" />
1094 </symbol>
1095 <symbol label="r">
1096 <feature value="1" name="sonorant" />
1097 <feature value="1" name="anterior" />
1098 <feature value="1" name="approximant" />
1099 </symbol>
1100  
1101 <!-- Postalveolar -->
1102 <symbol label="tS">
1103 <feature value="0" name="anterior" />
1104 <feature value="0" name="continuant" />
1105 <feature value="1" name="distributed" />
1106 </symbol>
1107 <symbol label="dZ">
1108 <feature value="1" name="voice" />
1109 <feature value="0" name="anterior" />
1110 <feature value="0" name="continuant" />
1111 <feature value="1" name="distributed" />
1112 </symbol>
1113 <symbol label="S">
1114 <feature value="0" name="anterior" />
1115 <feature value="1" name="continuant" />
1116 <feature value="1" name="distributed" />
1117 </symbol>
1118 <symbol label="Z">
1119 <feature value="1" name="voice" />
1120 <feature value="0" name="anterior" />
1121 <feature value="1" name="continuant" />
1122 <feature value="1" name="distributed" />
1123 </symbol>
1124  
1125 <!-- Retroflex -->
1126 <symbol label="t`">
1127 <feature value="0" name="anterior" />
1128 <feature value="0" name="continuant" />
1129 <feature value="0" name="distributed" />
1130 </symbol>
1131 <symbol label="d`">
1132 <feature value="1" name="voice" />
1133 <feature value="0" name="anterior" />
1134 <feature value="0" name="continuant" />
1135 <feature value="0" name="distributed" />
1136 </symbol>
1137 <symbol label="s`">
1138 <feature value="0" name="anterior" />
1139 <feature value="1" name="continuant" />
1140 <feature value="0" name="distributed" />
1141 </symbol>
1142 <symbol label="z`">
1143 <feature value="1" name="voice" />
1144 <feature value="0" name="anterior" />
1145 <feature value="1" name="continuant" />
1146 <feature value="0" name="distributed" />
1147 </symbol>
1148 <symbol label="n`">
1149 <feature value="1" name="sonorant" />
1150 <feature value="0" name="anterior" />
1151 <feature value="0" name="continuant" />
1152 <feature value="1" name="nasal" />
1153 <feature value="0" name="distributed" />
1154 </symbol>
1155 <symbol label="l`">
1156 <feature value="1" name="lateral" />
1157 <feature value="1" name="sonorant" />
1158 <feature value="0" name="anterior" />
1159 <feature value="0" name="distributed" />
1160 <feature value="1" name="approximant" />
1161 </symbol>
1162 <symbol label="r`">
1163 <feature value="1" name="sonorant" />
1164 <feature value="0" name="anterior" />
1165 <feature value="0" name="distributed" />
1166 <feature value="1" name="approximant" />
1167 </symbol>
1168  
1169 <!-- Palatal -->
1170 <symbol label="c">
1171 <feature value="0" name="continuant" />
1172 <feature value="0" name="anterior" />
1173 <feature value="1" name="dorsal" />
1174 </symbol>
1175 <symbol label="d\">
1176 <feature value="1" name="voice" />
1177 <feature value="0" name="anterior" />
1178 <feature value="0" name="continuant" />
1179 <feature value="1" name="dorsal" />
1180 </symbol>
1181 <symbol label="C">
1182 <feature value="0" name="anterior" />
1183 <feature value="1" name="continuant" />
1184 <feature value="1" name="dorsal" />
1185 </symbol>
1186 <symbol label="j\">
1187 <feature value="1" name="voice" />
1188 <feature value="0" name="anterior" />
1189 <feature value="1" name="continuant" />
1190 <feature value="1" name="dorsal" />
1191 </symbol>
1192 <symbol label="J">
1193 <feature value="1" name="sonorant" />
1194 <feature value="0" name="anterior" />
1195 <feature value="0" name="continuant" />
1196 <feature value="1" name="nasal" />
1197 <feature value="1" name="dorsal" />
1198 </symbol>
1199 <symbol label="L">
1200 <feature value="1" name="lateral" />
1201 <feature value="1" name="sonorant" />
1202 <feature value="0" name="anterior" />
1203 <feature value="1" name="approximant" />
1204 <feature value="1" name="dorsal" />
1205 </symbol>
1206  
1207 <!-- Velar -->
1208 <symbol label="k">
1209 <feature value="0" name="continuant" />
1210 <feature value="1" name="dorsal" />
1211 </symbol>
1212 <symbol label="g">
1213 <feature value="1" name="voice" />
1214 <feature value="0" name="continuant" />
1215 <feature value="1" name="dorsal" />
1216 </symbol>
1217 <symbol label="x">
1218 <feature value="1" name="continuant" />
1219 <feature value="1" name="dorsal" />
1220 </symbol>
1221 <symbol label="G">
1222 <feature value="1" name="voice" />
1223 <feature value="1" name="continuant" />
1224 <feature value="1" name="dorsal" />
1225 </symbol>
1226 <symbol label="N">
1227 <feature value="1" name="sonorant" />
1228 <feature value="0" name="continuant" />
1229 <feature value="1" name="nasal" />
1230 <feature value="1" name="dorsal" />
1231 </symbol>
1232  
1233 <!-- Uvular -->
1234 <symbol label="q">
1235 <feature value="1" name="pharyngeal" />
1236 <feature value="0" name="continuant" />
1237 <feature value="1" name="dorsal" />
1238 </symbol>
1239 <symbol label="G\">
1240 <feature value="1" name="voice" />
1241 <feature value="1" name="pharyngeal" />
1242 <feature value="0" name="continuant" />
1243 <feature value="1" name="dorsal" />
1244 </symbol>
1245 <symbol label="X">
1246 <feature value="1" name="pharyngeal" />
1247 <feature value="1" name="continuant" />
1248 <feature value="1" name="dorsal" />
1249 </symbol>
1250 <symbol label="R">
1251 <feature value="1" name="voice" />
1252 <feature value="1" name="pharyngeal" />
1253 <feature value="1" name="continuant" />
1254 <feature value="1" name="dorsal" />
1255 </symbol>
1256 <symbol label="N\">
1257 <feature value="1" name="sonorant" />
1258 <feature value="1" name="pharyngeal" />
1259 <feature value="0" name="continuant" />
1260 <feature value="1" name="nasal" />
1261 <feature value="1" name="dorsal" />
1262 </symbol>
1263 <symbol label="R\">
1264 <feature value="1" name="sonorant" />
1265 <feature value="1" name="pharyngeal" />
1266 <feature value="1" name="approximant" />
1267 <feature value="1" name="dorsal" />
1268 </symbol>
1269  
1270 <!-- Pharyngeal -->
1271 <symbol label="q\">
1272 <feature value="1" name="pharyngeal" />
1273 <feature value="0" name="continuant" />
1274 </symbol>
1275 <symbol label="X\">
1276 <feature value="1" name="pharyngeal" />
1277 <feature value="1" name="continuant" />
1278 </symbol>
1279 <symbol label="?\">
1280 <feature value="1" name="voice" />
1281 <feature value="1" name="pharyngeal" />
1282 <feature value="1" name="continuant" />
1283 </symbol>
1284  
1285 <!-- Glottal -->
1286 <symbol label="?">
1287 <feature value="*" name="Place" />
1288 <feature value="0" name="continuant" />
1289 </symbol>
1290 <symbol label="h">
1291 <feature value="*" name="Place" />
1292 <feature value="1" name="continuant" />
1293 </symbol>
1294 <symbol label="h\">
1295 <feature value="*" name="Place" />
1296 <feature value="1" name="voice" />
1297 <feature value="1" name="continuant" />
1298 </symbol>
1299  
1300  
1301 <!-- Vowels -->
1302 <!-- High Front Vowels -->
1303 <symbol label="i">
1304 <feature value="1" name="tense" />
1305 <feature value="1" name="sonorant" />
1306 <feature value="0" name="anterior" />
1307 <feature value="1" name="vocoid" />
1308 <feature value="0" name="aperture" />
1309 <feature value="1" name="approximant" />
1310 </symbol>
1311 <symbol label="I">
1312 <feature value="1" name="sonorant" />
1313 <feature value="0" name="anterior" />
1314 <feature value="1" name="vocoid" />
1315 <feature value="0" name="aperture" />
1316 <feature value="1" name="approximant" />
1317 </symbol>
1318 <symbol label="y">
1319 <feature value="1" name="tense" />
1320 <feature value="1" name="sonorant" />
1321 <feature value="0" name="anterior" />
1322 <feature value="1" name="vocoid" />
1323 <feature value="0" name="aperture" />
1324 <feature value="1" name="labial" />
1325 <feature value="1" name="approximant" />
1326 </symbol>
1327 <symbol label="Y">
1328 <feature value="1" name="sonorant" />
1329 <feature value="0" name="anterior" />
1330 <feature value="1" name="vocoid" />
1331 <feature value="0" name="aperture" />
1332 <feature value="1" name="labial" />
1333 <feature value="1" name="approximant" />
1334 </symbol>
1335 <symbol label="j">
1336 <feature value="1" name="tense" />
1337 <feature value="1" name="sonorant" />
1338 <feature value="0" name="anterior" />
1339 <feature value="1" name="vocoid" />
1340 <feature value="*" name="nucleus" />
1341 <feature value="0" name="aperture" />
1342 <feature value="1" name="approximant" />
1343 </symbol>
1344 <symbol label="H">
1345 <feature value="1" name="tense" />
1346 <feature value="1" name="sonorant" />
1347 <feature value="0" name="anterior" />
1348 <feature value="1" name="vocoid" />
1349 <feature value="*" name="nucleus" />
1350 <feature value="0" name="aperture" />
1351 <feature value="1" name="approximant" />
1352 <feature value="1" name="labial" />
1353 </symbol>
1354  
1355 <!-- High Back Vowels -->
1356 <symbol label="u">
1357 <feature value="1" name="tense" />
1358 <feature value="1" name="sonorant" />
1359 <feature value="1" name="vocoid" />
1360 <feature value="0" name="aperture" />
1361 <feature value="1" name="labial" />
1362 <feature value="1" name="dorsal" />
1363 <feature value="1" name="approximant" />
1364 </symbol>
1365 <symbol label="U">
1366 <feature value="1" name="sonorant" />
1367 <feature value="1" name="vocoid" />
1368 <feature value="0" name="aperture" />
1369 <feature value="1" name="labial" />
1370 <feature value="1" name="dorsal" />
1371 <feature value="1" name="approximant" />
1372 </symbol>
1373 <symbol label="M">
1374 <feature value="1" name="sonorant" />
1375 <feature value="1" name="vocoid" />
1376 <feature value="0" name="aperture" />
1377 <feature value="1" name="labial" />
1378 <feature value="1" name="dorsal" />
1379 <feature value="1" name="approximant" />
1380 </symbol>
1381 <symbol label="w">
1382 <feature value="1" name="tense" />
1383 <feature value="1" name="sonorant" />
1384 <feature value="1" name="vocoid" />
1385 <feature value="*" name="nucleus" />
1386 <feature value="0" name="aperture" />
1387 <feature value="1" name="approximant" />
1388 <feature value="1" name="dorsal" />
1389 <feature value="1" name="labial" />
1390 </symbol>
1391  
1392 <!-- High Central Vowels -->
1393 <symbol label="1">
1394 <feature value="1" name="sonorant" />
1395 <feature value="1" name="vocoid" />
1396 <feature value="0" name="aperture" />
1397 <feature value="1" name="approximant" />
1398 </symbol>
1399 <symbol label="}">
1400 <feature value="1" name="sonorant" />
1401 <feature value="1" name="vocoid" />
1402 <feature value="0" name="aperture" />
1403 <feature value="1" name="labial" />
1404 <feature value="1" name="approximant" />
1405 </symbol>
1406  
1407 <!-- Mid Front Vowels -->
1408 <symbol label="e">
1409 <feature value="1" name="tense" />
1410 <feature value="1" name="sonorant" />
1411 <feature value="0" name="anterior" />
1412 <feature value="1" name="vocoid" />
1413 <feature value="1" name="aperture" />
1414 <feature value="1" name="approximant" />
1415 </symbol>
1416 <symbol label="E">
1417 <feature value="1" name="sonorant" />
1418 <feature value="0" name="anterior" />
1419 <feature value="1" name="vocoid" />
1420 <feature value="1" name="aperture" />
1421 <feature value="1" name="approximant" />
1422 </symbol>
1423 <symbol label="2">
1424 <feature value="1" name="tense" />
1425 <feature value="1" name="sonorant" />
1426 <feature value="0" name="anterior" />
1427 <feature value="1" name="vocoid" />
1428 <feature value="1" name="aperture" />
1429 <feature value="1" name="approximant" />
1430 <feature value="1" name="labial" />
1431 </symbol>
1432 <symbol label="9">
1433 <feature value="1" name="sonorant" />
1434 <feature value="0" name="anterior" />
1435 <feature value="1" name="vocoid" />
1436 <feature value="1" name="aperture" />
1437 <feature value="1" name="approximant" />
1438 <feature value="1" name="labial" />
1439 </symbol>
1440  
1441 <!-- Mid Back Vowels -->
1442 <symbol label="o">
1443 <feature value="1" name="tense" />
1444 <feature value="1" name="sonorant" />
1445 <feature value="1" name="vocoid" />
1446 <feature value="1" name="aperture" />
1447 <feature value="1" name="labial" />
1448 <feature value="1" name="dorsal" />
1449 <feature value="1" name="approximant" />
1450 </symbol>
1451 <symbol label="O">
1452 <feature value="1" name="sonorant" />
1453 <feature value="1" name="vocoid" />
1454 <feature value="1" name="aperture" />
1455 <feature value="1" name="labial" />
1456 <feature value="1" name="dorsal" />
1457 <feature value="1" name="approximant" />
1458 </symbol>
1459 <symbol label="W">
1460 <feature value="1" name="tense" />
1461 <feature value="1" name="sonorant" />
1462 <feature value="1" name="vocoid" />
1463 <feature value="1" name="aperture" />
1464 <feature value="1" name="dorsal" />
1465 <feature value="1" name="approximant" />
1466 </symbol>
1467 <symbol label="V">
1468 <feature value="1" name="sonorant" />
1469 <feature value="1" name="vocoid" />
1470 <feature value="1" name="aperture" />
1471 <feature value="1" name="dorsal" />
1472 <feature value="1" name="approximant" />
1473 </symbol>
1474  
1475 <!-- Mid Central Vowels -->
1476 <symbol label="@">
1477 <feature value="1" name="sonorant" />
1478 <feature value="1" name="vocoid" />
1479 <feature value="1" name="aperture" />
1480 <feature value="1" name="approximant" />
1481 </symbol>
1482 <symbol label="8">
1483 <feature value="1" name="sonorant" />
1484 <feature value="1" name="vocoid" />
1485 <feature value="1" name="aperture" />
1486 <feature value="1" name="labial" />
1487 <feature value="1" name="approximant" />
1488 </symbol>
1489  
1490 <!-- Low Vowels -->
1491 <symbol label="a">
1492 <feature value="1" name="sonorant" />
1493 <feature value="1" name="vocoid" />
1494 <feature value="2" name="aperture" />
1495 <feature value="1" name="approximant" />
1496 </symbol>
1497 <symbol label="Q">
1498 <feature value="1" name="sonorant" />
1499 <feature value="1" name="vocoid" />
1500 <feature value="2" name="aperture" />
1501 <feature value="1" name="labial" />
1502 <feature value="1" name="approximant" />
1503 </symbol>
1504  
1505 <!-- Diacritics -->
1506 <symbol label="*~">
1507 <feature value="1" name="nasal" />
1508 </symbol>
1509 <symbol label="*_?\">
1510 <feature value="1" name="pharyngeal" />
1511 </symbol>
1512 <symbol label="*_v">
1513 <feature value="1" name="voice" />
1514 </symbol>
1515 <symbol label="*_h">
1516 <feature value="1" name="spread" />
1517 </symbol>
1518 <symbol label="*_w">
1519 <feature value="1" name="labial" />
1520 </symbol>
1521 <symbol label="*_l">
1522 <feature value="1" name="lateral" />
1523 </symbol>
1524 <symbol label="*_~">
1525 <feature value="1" name="constricted" />
1526 </symbol>
1527 <symbol label="*_G">
1528 <feature value="1" name="dorsal" />
1529 </symbol>
1530 <symbol label="*_0">
1531 <feature value="*" name="voice" />
1532 </symbol>
1533 <symbol label="*_d">
1534 <feature value="1" name="distributed" />
1535 </symbol>
1536  
1537 </symbols>
1538 </phonology>
1539  
1540  
1541 These symbols depend upon the default feature set. If you aren't using the
1542 default feature set, you're on your own. If you've modified the default
1543 feature set, these may still work, though you'll probably have to tweak
1544 them. YMMV.
1545  
1546 =head1 SEE ALSO
1547  
1548 Lingua::Phonology, Lingua::Phonology::Features
1549  
1550 =head1 AUTHOR
1551  
1552 Jesse S. Bangs <F<jaspax@cpan.org>>
1553  
1554 =head1 LICENSE
1555  
1556 This module is free software. You can distribute and/or modify it under the
1557 same terms as Perl itself.
1558  
1559 =cut
1560  
1561 __DATA__
« Phonology/Segment/Tier.pm ↑ Summary Phonology/Segment.pm »