pdf - Universität zu Köln
pdf - Universität zu Köln
pdf - Universität zu Köln
Erfolgreiche ePaper selbst erstellen
Machen Sie aus Ihren PDF Publikationen ein blätterbares Flipbook mit unserer einzigartigen Google optimierten e-Paper Software.
# counts syllables in input text by using splitBySonority.<br />
sub countSyllables<br />
{<br />
my ($self,$text)=@_;<br />
#handle foreign characters<br />
$text=convertChars($text);<br />
my $out=$self->splitBySonority($text);<br />
$out =~s/\-\-/-/g;<br />
$out =~s/o(h?a)/o-$1/g;<br />
#handle oa as syllable boundary<br />
}<br />
my @out =split ’-’,$out;<br />
return scalar @out;<br />
#split text by maximising onsets. As we are using graphemes, some of them have to be<br />
#multiple characters long e.g. or <br />
sub splitBySonority<br />
{<br />
my ($self,$name)=@_;<br />
my $pos = 0;<br />
my @units;<br />
#build array of graphemic units. these are graphemes, that are not<br />
#separatable and would result in wrong minima, if matched as single graphemes<br />
while ($pos < length ($name))<br />
{<br />
my $match;<br />
#first try to match<br />
foreach my $m (@multichar)<br />
{<br />
$match = $m, last if ((substr $name,$pos,length ($m)) eq $m);<br />
}<br />
#use current char, if multiple characters do not match<br />
$match ||= substr $name,$pos,1;<br />
72