File Coverage

lib/Lingua/JA/Romaji/Valid/Filter/Word.pm
Criterion Covered Total %
statement 26 26 100.0
branch 4 4 100.0
condition n/a
subroutine 10 10 100.0
pod 8 8 100.0
total 48 48 100.0


line stmt bran cond sub pod time code
1             package Lingua::JA::Romaji::Valid::Filter::Word;
2              
3 4     4   21 use strict;
  4         7  
  4         123  
4 4     4   21 use warnings;
  4         6  
  4         2143  
5              
6 308     308 1 1896 sub new { bless {}, shift }
7              
8             sub normalize_n_with_apostrophe {
9 271     271 1 357 my ($self, $word_ref) = @_;
10              
11 271         1560 $$word_ref =~ s/n\\?'([aeiouy])/n$1/g;
12              
13 271         1006 return 1;
14             }
15              
16             sub normalize_n_with_hyphen {
17 68     68 1 108 my ($self, $word_ref) = @_;
18              
19 68         272 $$word_ref =~ s/n\\?[\-]([aeiouy])/n$1/g;
20              
21 68         263 return 1;
22             }
23              
24             sub normalize_oh {
25 34     34 1 61 my ($self, $word_ref) = @_;
26              
27             # strictly speaking, this may be wrong (eg. o-hira, not oh-ira)
28             # but both cases should be valid in the end.
29 34         175 $$word_ref =~ s/oh/o/g;
30              
31 34         133 return 1;
32             }
33              
34             sub normalize_long_vowel_with_h {
35 34     34 1 46 my ($self, $word_ref) = @_;
36              
37             # strictly speaking, this may be wrong (eg. o-hira, not oh-ira)
38             # but both cases should be valid in the end.
39 34         105 $$word_ref =~ s/([aeiou])h/$1/g;
40              
41 34         113 return 1;
42             }
43              
44             sub normalize_long_vowel_with_symbols {
45 34     34 1 55 my ($self, $word_ref) = @_;
46              
47             # strictly speaking, this may be wrong (eg. o-hira, not oh-ira)
48             # but both cases should be valid in the end.
49 34         140 $$word_ref =~ s/([aeiou])\\?[_\-^]/$1/g;
50              
51 34         118 return 1;
52             }
53              
54             sub prohibit_initial_n {
55 26     26 1 35 my ($self, $word_ref) = @_;
56              
57 26 100       124 return ( $$word_ref =~ /^n(?:[^aeiouy])/ ) ? 0 : 1;
58             }
59              
60             sub prohibit_initial_wo {
61 25     25 1 39 my ($self, $word_ref) = @_;
62              
63 25 100       101 return ( $$word_ref =~ /^wo/ ) ? 0 : 1;
64             }
65              
66             1;
67              
68             __END__