line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::MultiPhone; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
56649
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
48
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
1137
|
|
|
1
|
|
|
|
|
46
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
75
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use constant VOWELS => [qw(a e i o u)]; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
752
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
0
|
0
|
my ($class) = @_; |
13
|
0
|
|
|
|
|
0
|
return bless {}, $class; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub multiphone { |
17
|
3
|
|
|
3
|
0
|
49
|
my ($self, $word) = @_; |
18
|
3
|
|
|
|
|
18
|
$word = $self->pre_split($word); |
19
|
3
|
|
|
|
|
27
|
my @words = $self->do_split($word); |
20
|
3
|
|
|
|
|
15
|
@words = $self->process_bits(@words); |
21
|
3
|
|
|
|
|
20
|
@words = $self->do_join(@words); |
22
|
3
|
|
|
|
|
13
|
@words = $self->post_join(@words); |
23
|
3
|
|
|
|
|
21
|
return @words; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _warn { |
27
|
0
|
|
|
0
|
|
0
|
my ($self, @warn) = @_; |
28
|
0
|
|
|
|
|
0
|
warn (@warn); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub pre_split { |
32
|
0
|
|
|
0
|
0
|
0
|
$_[0]->_warn((caller(0))[3] . " not defined in $_[0]\n"); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# a word consist of 2 levels of arrays |
36
|
|
|
|
|
|
|
# 1. level splits vowels and consonants |
37
|
|
|
|
|
|
|
# 2. level splits several meanings of this vowel or consonant |
38
|
|
|
|
|
|
|
# i.e. Alphabet will be [[a],[lf],[a], [b], [t] ] |
39
|
|
|
|
|
|
|
sub do_split { |
40
|
3
|
|
|
3
|
0
|
8
|
my ($self, @words) = @_; |
41
|
3
|
|
|
|
|
14
|
my @results; |
42
|
3
|
|
|
|
|
5
|
my $vowels = join "", @{ $self->VOWELS() }; |
|
3
|
|
|
|
|
19
|
|
43
|
3
|
|
|
|
|
6
|
foreach my $word (@words) { |
44
|
3
|
|
|
|
|
4
|
my @splitted; |
45
|
3
|
|
|
|
|
131
|
while ($word =~ m/([$vowels]*)([^$vowels]*)/g) { |
46
|
12
|
|
|
|
|
102
|
push @splitted, [$1], [$2]; |
47
|
|
|
|
|
|
|
} |
48
|
3
|
|
|
|
|
10
|
push @results, \@splitted; |
49
|
|
|
|
|
|
|
} |
50
|
3
|
|
|
|
|
13
|
return @results; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub process_bits { |
54
|
0
|
|
|
0
|
0
|
0
|
$_[0]->_warn((caller(0))[3] . " not defined in $_[0]\n"); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub do_join { |
58
|
3
|
|
|
3
|
0
|
6
|
my ($self, @words) = @_; |
59
|
3
|
|
|
|
|
8
|
my @results = (""); |
60
|
3
|
|
|
|
|
11
|
foreach my $word (@words) { |
61
|
3
|
50
|
|
|
|
8
|
next unless defined $word; |
62
|
3
|
|
|
|
|
5
|
foreach my $part (@$word) { |
63
|
24
|
50
|
|
|
|
45
|
next unless defined $part; |
64
|
24
|
|
|
|
|
27
|
my @newResults; |
65
|
24
|
|
|
|
|
39
|
foreach my $splitPart (@$part) { |
66
|
24
|
50
|
|
|
|
34
|
next unless defined $splitPart; |
67
|
24
|
|
|
|
|
37
|
foreach my $result (@results) { |
68
|
24
|
|
|
|
|
74
|
push @newResults, $result . $splitPart; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
24
|
|
|
|
|
57
|
@results = @newResults; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
3
|
|
|
|
|
17
|
return @results; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub post_join { |
78
|
0
|
|
|
0
|
0
|
|
$_[0]->_warn((caller(0))[3] . " not defined in $_[0]\n"); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
__END__ |