line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::FI::Hyphenate; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Lingua::FI::Hyphenate - Finnish hyphenation (suomen tavutus) |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NIMI |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Lingua::FI::Hyphenate - suomen tavutus |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Lingua::FI::Hyphenate qw(tavuta); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my @tavut = tavuta("kodeissansakaan"); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
print "@tavut\n"; # will print "ko deis san sa kaan\n"; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 KÄYTTÖ |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Lingua::FI::Hyphenate qw(tavuta); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my @tavut = tavuta("kodeissansakaan"); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
print "@tavut\n"; # tulostaa "ko deis san sa kaan\n"; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
tavuta() returns as a list the syllables of its Finnish input list. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
The used character set is ISO 8859-1, of which the Finnish word |
32
|
|
|
|
|
|
|
characters the vowels are |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
aeiouyäåö AEIOUYÅÄÖ |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
and the consonants are |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
bcdfghjklmnpqrstvwxz BCDFGHJKLMNPQRSTVWXZ |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
The rules for syllable divisions are: |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=over 4 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item * |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
B any consonant-vowel pair I when the said consonant is |
47
|
|
|
|
|
|
|
the latter consonant of a syllable-initial consonant-consonant pair. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item * |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
B any vowel-vowel pair I when the vowel pair is a |
52
|
|
|
|
|
|
|
Finnish diphthong, that is any of the I
|
53
|
|
|
|
|
|
|
ui uo yi yö äi äy öi öy>. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=back |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 KUVAUS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
tavuta() palauttaa listana suomenkielisen syötelistansa tavut. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Käytetty merkistö on ISO 8859-1, suomenkieliset vokaalit ovat |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
aeiouyäåö AEIOUYÅÄÖ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
ja konsonantit ovat |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
bcdfghjklmnpqrstvwxz BCDFGHJKLMNPQRSTVWXZ |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Tavujakosäännöt ovat: |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over 4 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
B jokaista konsonantti-vokaali-paria I kun mainittu |
76
|
|
|
|
|
|
|
konsonantti on tavunalkuisen konsonantti-konsonantti-parin jälkimmäinen. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Jokaisen vokaali-vokaali-parin B I kun vokaalipari on |
81
|
|
|
|
|
|
|
suomen diftongi, eli jokin seuraavista: I
|
82
|
|
|
|
|
|
|
oi ou ui uo yi yö äi äy öi öy>. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 CAVEAT |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
tavuta() works only for single words. Compound words may get wrongly |
87
|
|
|
|
|
|
|
hyphenated, especially when the first component ends in a consonant |
88
|
|
|
|
|
|
|
and the second component begins with a vowel. For example, |
89
|
|
|
|
|
|
|
"kaivosaukko" ('the opening of a mine', compound of "kaivos", 'mine', |
90
|
|
|
|
|
|
|
and "aukko", 'opening') will be wrongly hyphenated as "kai-vo-sauk-ko" |
91
|
|
|
|
|
|
|
('well otter'). Caveat hyphenator. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
You may hint the correct word/syllable division by inserting a "-" at |
94
|
|
|
|
|
|
|
the right places. In fact, any non-Finnish word characters are |
95
|
|
|
|
|
|
|
removed and replaced with syllable divisions. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 VAROITUS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
tavuta() toimii vain yksittäisille sanoille. Sanaliitot saattavat |
100
|
|
|
|
|
|
|
tavuttua väärin, varsinkin jos ensimmäinen osa päättyy konsonanttiin |
101
|
|
|
|
|
|
|
ja toinen osa alkaa vokaalilla. Esimerkiksi "kaivosaukko" tavuttuu |
102
|
|
|
|
|
|
|
väärin: "kai-vo-sauk-ko". Tarkkavaisuutta tavutukseen. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Voit antaa tavutusvihjeitä käyttämällä "-"-merkkiä sopivissa kohdissa. |
105
|
|
|
|
|
|
|
Itse asiassa kaikki paitsi kirjaimet poistetaan ja korvataan tavurajoilla. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Jarkko Hietaniemi |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 COPYRIGHT |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Copyright 2001 Jarkko Hietaniemi |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 LICENSE |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
118
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 TEKIJÄ |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Jarkko Hietaniemi |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 TEKIJÄNOIKEUS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Copyright 2001 Jarkko Hietaniemi |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 LISENSSI |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Tämä kirjastomoduli on vapaa; voit jakaa ja/tai muuttaa sitä samojen |
131
|
|
|
|
|
|
|
ehtojen mukaisesti kuin Perliä itseään. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
1
|
|
944
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
136
|
|
|
|
|
|
|
|
137
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT_OK); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1605
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$VERSION = '0.04'; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
require Exporter; |
142
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
143
|
|
|
|
|
|
|
@EXPORT_OK = qw(tavuta); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Hardcode the character classes instead of depending on locales. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my $v = "aeiouyäåöAEIOUYÅÄÖ"; |
148
|
|
|
|
|
|
|
my $k = "bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ"; |
149
|
|
|
|
|
|
|
my $V = "[$v]"; |
150
|
|
|
|
|
|
|
my $K = "[$k]"; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $VU = 0; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub tavuta { |
155
|
15
|
|
|
15
|
0
|
122
|
my (@sanat) = @_; |
156
|
|
|
|
|
|
|
|
157
|
15
|
|
|
|
|
27
|
my @tavut = @sanat; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# Anything not a letter is a syllable division. |
160
|
|
|
|
|
|
|
|
161
|
15
|
|
|
|
|
20
|
@tavut = map { split /[^$v$k]+/ } @tavut; |
|
15
|
|
|
|
|
182
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# Syllable division before any KV. |
164
|
|
|
|
|
|
|
# Exception: the rare loanword-based ^KK syllables. |
165
|
|
|
|
|
|
|
|
166
|
15
|
|
|
|
|
23
|
@tavut = map { split /(?=(?
|
|
18
|
|
|
|
|
219
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# Syllable division between any VV pair |
169
|
|
|
|
|
|
|
# that is not a Finnish diphtong. |
170
|
|
|
|
|
|
|
|
171
|
15
|
|
|
|
|
25
|
@tavut = map { split /(.*?[aA])(?=[eoEO])/ } @tavut; |
|
48
|
|
|
|
|
176
|
|
172
|
15
|
|
|
|
|
28
|
@tavut = map { split /(.*?[eiEI])(?=[aoäöAOÄÖ])/ } @tavut; |
|
48
|
|
|
|
|
131
|
|
173
|
15
|
|
|
|
|
20
|
@tavut = map { split /(.*?[ouOU])(?=[aeAE])/ } @tavut; |
|
48
|
|
|
|
|
133
|
|
174
|
15
|
|
|
|
|
24
|
@tavut = map { split /(.*?[yäYÄ])(?=[eäEÄ])/ } @tavut; |
|
50
|
|
|
|
|
135
|
|
175
|
15
|
|
|
|
|
26
|
@tavut = map { split /(.*?[öÖ])(?=[eE])/ } @tavut; |
|
49
|
|
|
|
|
126
|
|
176
|
|
|
|
|
|
|
|
177
|
15
|
50
|
|
|
|
36
|
if ($VU) { |
178
|
|
|
|
|
|
|
# TO DO - TEKEMÄTTÄ. |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
15
|
|
|
|
|
62
|
@tavut; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
1; |