| 1 | package Parse::JapanesePostalCode::Row; | ||||||||||||||||||||||||||||||||
| 2 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use utf8; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use Lingua::JA::Regular::Unicode qw/ katakana_h2z /; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 997 | ▶ | sub alnum_z2h { | ||||||||||||||||||||||||||||||
|
Subroutine
alnum_z2h: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 9 | 997 | my $str = shift; | |||||||||||||||||||||||||||||||
| 10 | 997 | $str = Lingua::JA::Regular::Unicode::alnum_z2h($str); | |||||||||||||||||||||||||||||||
| 11 | 997 | $str =~ tr/~−/〜-/; | |||||||||||||||||||||||||||||||
| 12 | 997 | $str; | |||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 16 | my @COLUMNS = qw/ | |||||||||||||||||||||||||||||||
| 16 | region_id old_zip zip | ||||||||||||||||||||||||||||||||
| 17 | pref_kana region_kana town_kana pref region town | ||||||||||||||||||||||||||||||||
| 18 | is_multi_zip has_koaza_banchi has_chome is_multi_town | ||||||||||||||||||||||||||||||||
| 19 | update_status update_reason | ||||||||||||||||||||||||||||||||
| 20 | /; | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 16 | my @METHODS = (@COLUMNS, qw/ | |||||||||||||||||||||||||||||||
| 23 | district district_kana city city_kana ward ward_kana | ||||||||||||||||||||||||||||||||
| 24 | subtown_kana subtown | ||||||||||||||||||||||||||||||||
| 25 | build build_kana floor | ||||||||||||||||||||||||||||||||
| 26 | /); | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 16 | for my $name (@METHODS) { | |||||||||||||||||||||||||||||||
| 29 | 2301 | ▶ | my $sub = sub { $_[0]->{columns}{$name} }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 30 | 16 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 31 | 416 | *{$name} = $sub; | |||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 75 | ▶ | sub columns { @COLUMNS } | ||||||||||||||||||||||||||||||
|
Subroutine
columns: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 89 | ▶ | sub has_subtown { !! $_[0]->subtown } | ||||||||||||||||||||||||||||||
|
Subroutine
has_subtown: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 75 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 39 | 75 | my($class, %opts) = @_; | |||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 75 | my $columns = {}; | |||||||||||||||||||||||||||||||
| 42 | 75 | for my $column (@COLUMNS) { | |||||||||||||||||||||||||||||||
| 43 | 1125 | ▶ | $columns->{$column} = delete $opts{$column} if defined $opts{$column}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 75 | my $self = bless { | |||||||||||||||||||||||||||||||
| 47 | katakana_h2z => 1, | ||||||||||||||||||||||||||||||||
| 48 | alnum_z2h => 1, | ||||||||||||||||||||||||||||||||
| 49 | build_town => '', | ||||||||||||||||||||||||||||||||
| 50 | build_town_kana => '', | ||||||||||||||||||||||||||||||||
| 51 | %opts, | ||||||||||||||||||||||||||||||||
| 52 | columns => $columns, | ||||||||||||||||||||||||||||||||
| 53 | }, $class; | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 75 | $self->fix_region; | |||||||||||||||||||||||||||||||
| 56 | 75 | $self->fix_town; | |||||||||||||||||||||||||||||||
| 57 | 75 | $self->fix_build; | |||||||||||||||||||||||||||||||
| 58 | 75 | ▶ | $self->fix_subtown unless $self->build; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 59 | 75 | $self->fix_kana_alnum; | |||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | 75 | $self; | |||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 75 | ▶ | sub fix_region { | ||||||||||||||||||||||||||||||
|
Subroutine
fix_region: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 65 | 75 | my $self = shift; | |||||||||||||||||||||||||||||||
| 66 | 75 | my $columns = $self->{columns}; | |||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | 75 | $columns->{district} = undef; | |||||||||||||||||||||||||||||||
| 69 | 75 | $columns->{district_kana} = undef; | |||||||||||||||||||||||||||||||
| 70 | 75 | $columns->{city} = undef; | |||||||||||||||||||||||||||||||
| 71 | 75 | $columns->{city_kana} = undef; | |||||||||||||||||||||||||||||||
| 72 | 75 | $columns->{ward} = undef; | |||||||||||||||||||||||||||||||
| 73 | 75 | $columns->{ward_kana} = undef; | |||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | # district | ||||||||||||||||||||||||||||||||
| 76 | 75 | my($district, $town_village) = $self->region =~ /^(.+?郡)(.+[町村])$/; | |||||||||||||||||||||||||||||||
| 77 | 75 | ▶ | if ($district && $town_village) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$district and $town_village
MC/DC50%1/2
$district and $town_village
$district
$town_village
Truth table66%2/3
A and B
A= $districtB= $town_village
| |||||||||||||||||||||||||||||||||
| 78 | 25 | my($district_kana, $town_village_kana) = $self->region_kana =~ /^((?:キタグンマ|.+?)グン)(.+)$/; | |||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | 25 | $columns->{district} = $district; | |||||||||||||||||||||||||||||||
| 81 | 25 | $columns->{district_kana} = $district_kana; | |||||||||||||||||||||||||||||||
| 82 | 25 | $columns->{city} = $town_village; | |||||||||||||||||||||||||||||||
| 83 | 25 | $columns->{city_kana} = $town_village_kana; | |||||||||||||||||||||||||||||||
| 84 | } else { | ||||||||||||||||||||||||||||||||
| 85 | 50 | my($city, $ward) = $self->region =~ /^(.+市)(.+区)$/; | |||||||||||||||||||||||||||||||
| 86 | 50 | ▶ | if ($city && $ward) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$city and $ward
MC/DC50%1/2
$city and $ward
$city
$ward
Truth table66%2/3
A and B
A= $cityB= $ward
| |||||||||||||||||||||||||||||||||
| 87 | 19 | my($city_kana, $ward_kana) = $self->region_kana =~ /^((?:ヒロシマ|キタキュウシュウ|.+?)シ)(.+)$/; | |||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | 19 | $columns->{city} = $city; | |||||||||||||||||||||||||||||||
| 90 | 19 | $columns->{city_kana} = $city_kana; | |||||||||||||||||||||||||||||||
| 91 | 19 | $columns->{ward} = $ward; | |||||||||||||||||||||||||||||||
| 92 | 19 | $columns->{ward_kana} = $ward_kana; | |||||||||||||||||||||||||||||||
| 93 | } elsif ($self->region =~ /区$/) { | ||||||||||||||||||||||||||||||||
| 94 | 9 | $columns->{ward} = $self->region; | |||||||||||||||||||||||||||||||
| 95 | 9 | $columns->{ward_kana} = $self->region_kana; | |||||||||||||||||||||||||||||||
| 96 | } else { | ||||||||||||||||||||||||||||||||
| 97 | 22 | $columns->{city} = $self->region; | |||||||||||||||||||||||||||||||
| 98 | 22 | $columns->{city_kana} = $self->region_kana; | |||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | 75 | ▶ | sub fix_town { | ||||||||||||||||||||||||||||||
|
Subroutine
fix_town: called CC=9 SCAR=22.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 104 | 75 | my $self = shift; | |||||||||||||||||||||||||||||||
| 105 | 75 | my $columns = $self->{columns}; | |||||||||||||||||||||||||||||||
| 106 | 75 | ▶ | if ($columns->{town} eq '以下に掲載がない場合') { | ||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||
| 107 | 1 | $columns->{town_kana} = undef; | |||||||||||||||||||||||||||||||
| 108 | 1 | $columns->{town} = undef; | |||||||||||||||||||||||||||||||
| 109 | } elsif ($columns->{town} =~ /^(.+)の次に番地がくる場合/) { | ||||||||||||||||||||||||||||||||
| 110 | 2 | my $name = $1; | |||||||||||||||||||||||||||||||
| 111 | 2 | ▶ | if ($columns->{city} eq $name || $columns->{city} =~ /郡\Q$name\E$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$columns->{"city"} eq $name or $columns->{"city"} =~ /\x{90e1}\Q$name\E$/
MC/DC0%0/2
$columns->{"city"} eq $name or $columns->{"city"} =~ /\x{90e1}\Q$name\E$/
$columns->{"city"} eq $name
$columns->{"city"} =~ /\x{90e1}\Q$name\E$/
Truth table33%1/3
A or B
A= $columns->{"city"} eq $nameB= $columns->{"city"} =~ /\x{90e1}\Q$name\E$/
| |||||||||||||||||||||||||||||||||
| 112 | 2 | $columns->{town_kana} = undef; | |||||||||||||||||||||||||||||||
| 113 | 2 | $columns->{town} = undef; | |||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||
| 115 | } elsif ($columns->{town} =~ s/(その他)$//) { | ||||||||||||||||||||||||||||||||
| 116 | 2 | $columns->{town_kana} =~ s/\(ソノタ\)$//; | |||||||||||||||||||||||||||||||
| 117 | } elsif ($columns->{town} =~ /^(.+[町村])一円$/) { | ||||||||||||||||||||||||||||||||
| 118 | 2 | my $name = $1; | |||||||||||||||||||||||||||||||
| 119 | 2 | ▶ | if ($columns->{city} eq $name) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 120 | 2 | $columns->{town_kana} = undef; | |||||||||||||||||||||||||||||||
| 121 | 2 | $columns->{town} = undef; | |||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 75 | ▶ | $columns->{town} =~ s/[〜~]/〜/g if $columns->{town}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | 67 | ▶ | sub fix_subtown { | ||||||||||||||||||||||||||||||
|
Subroutine
fix_subtown: called CC=16 SCAR=27.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 129 | 67 | my $self = shift; | |||||||||||||||||||||||||||||||
| 130 | 67 | my $columns = $self->{columns}; | |||||||||||||||||||||||||||||||
| 131 | 67 | ▶ | return unless $columns->{town}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | 62 | my @subtown; | |||||||||||||||||||||||||||||||
| 134 | my @subtown_kana; | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | # chome | ||||||||||||||||||||||||||||||||
| 137 | 62 | ▶ | if ($columns->{town} =~ s/(([\d〜、]+)丁目)$//) { | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 138 | 5 | my $num = alnum_z2h($1); | |||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | my @nums = map { | ||||||||||||||||||||||||||||||||
| 141 | 8 | ▶ | if (/^(\d+)〜(\d+)$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 142 | 3 | ($1..$2); | |||||||||||||||||||||||||||||||
| 143 | } else { | ||||||||||||||||||||||||||||||||
| 144 | 5 | $_ | |||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||
| 146 | 5 | } map { alnum_z2h($_) } split /、/, $1; | |||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | 5 | @subtown = map { $_ . '丁目' } @nums; | |||||||||||||||||||||||||||||||
| 149 | 5 | @subtown_kana = map { $_ . 'チョウメ' } @nums; | |||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | 5 | $columns->{town_kana} =~ s/\([\d\-、]+チョウメ\)$//; | |||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||
| 153 | # chiwari | ||||||||||||||||||||||||||||||||
| 154 | elsif ($columns->{town} =~ /^[^\(]+地割/) { | ||||||||||||||||||||||||||||||||
| 155 | 5 | my($prefix, $koaza) = $columns->{town} =~ /^(.+\d+地割)(?:((.+)))?$/; | |||||||||||||||||||||||||||||||
| 156 | 5 | my($prefix_kana, $koaza_kana) = $columns->{town_kana} =~ /^(.+\d+チワリ)(?:\((.+)\))?$/; | |||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | 5 | my($aza, $chiwari) = $prefix =~ /^(.+?)第?(\d+地割.*)$/; | |||||||||||||||||||||||||||||||
| 159 | 5 | my($aza_kana, $chiwari_kana) = $prefix_kana =~ /^(.+?)(?:ダイ)?(\d+チワリ.*)$/; | |||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | 5 | ▶ | if ($chiwari =~ /〜/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 162 | my @tmp = map { | ||||||||||||||||||||||||||||||||
| 163 | 2 | ▶ | if (/\d+地割$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 164 | 4 | my $str = $_; | |||||||||||||||||||||||||||||||
| 165 | 4 | $str =~ s/^\Q$aza\E//; | |||||||||||||||||||||||||||||||
| 166 | 4 | $str =~ s/^第//; | |||||||||||||||||||||||||||||||
| 167 | 4 | "第$str"; | |||||||||||||||||||||||||||||||
| 168 | } else { | ||||||||||||||||||||||||||||||||
| 169 | 0 | $_; | |||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||
| 171 | } split /〜/, $chiwari; | ||||||||||||||||||||||||||||||||
| 172 | 2 | $chiwari = join '〜', @tmp; | |||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||
| 174 | 5 | ▶ | if ($chiwari_kana =~ /-/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 175 | my @tmp = map { | ||||||||||||||||||||||||||||||||
| 176 | 2 | ▶ | if (/\d+チワリ$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 177 | 4 | my $str = $_; | |||||||||||||||||||||||||||||||
| 178 | 4 | $str =~ s/^\Q$aza_kana\E//; | |||||||||||||||||||||||||||||||
| 179 | 4 | $str =~ s/^ダイ//; | |||||||||||||||||||||||||||||||
| 180 | 4 | "ダイ$str"; | |||||||||||||||||||||||||||||||
| 181 | } else { | ||||||||||||||||||||||||||||||||
| 182 | 0 | $_; | |||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||
| 184 | } split /-/, $chiwari_kana; | ||||||||||||||||||||||||||||||||
| 185 | 2 | $chiwari_kana = join '-', @tmp; | |||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | @subtown = map { | ||||||||||||||||||||||||||||||||
| 189 | 5 | ▶ | if (/\d+地割$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 190 | 6 | my $str = $_; | |||||||||||||||||||||||||||||||
| 191 | 6 | $str =~ s/^\Q$aza\E//; | |||||||||||||||||||||||||||||||
| 192 | 6 | $str =~ s/^第//; | |||||||||||||||||||||||||||||||
| 193 | 6 | "第$str"; | |||||||||||||||||||||||||||||||
| 194 | } else { | ||||||||||||||||||||||||||||||||
| 195 | 0 | $_; | |||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||
| 197 | } split /、/, $chiwari; | ||||||||||||||||||||||||||||||||
| 198 | @subtown_kana = map { | ||||||||||||||||||||||||||||||||
| 199 | 5 | ▶ | if (/\d+チワリ$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 200 | 6 | my $str = $_; | |||||||||||||||||||||||||||||||
| 201 | 6 | $str =~ s/^\Q$aza_kana\E//; | |||||||||||||||||||||||||||||||
| 202 | 6 | $str =~ s/^ダイ//; | |||||||||||||||||||||||||||||||
| 203 | 6 | "ダイ$str"; | |||||||||||||||||||||||||||||||
| 204 | } else { | ||||||||||||||||||||||||||||||||
| 205 | 0 | $_; | |||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||
| 207 | } split /、/, $chiwari_kana; | ||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||
| 209 | 5 | ▶ | if ($koaza) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 210 | @subtown = map { | ||||||||||||||||||||||||||||||||
| 211 | 2 | my $str = $_; | |||||||||||||||||||||||||||||||
| 212 | map { | ||||||||||||||||||||||||||||||||
| 213 | 2 | "$str $_"; | |||||||||||||||||||||||||||||||
| 214 | } split /、/, $koaza; | ||||||||||||||||||||||||||||||||
| 215 | } @subtown; | ||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||
| 217 | 5 | ▶ | if ($koaza_kana) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 218 | @subtown_kana = map { | ||||||||||||||||||||||||||||||||
| 219 | 2 | my $str = $_; | |||||||||||||||||||||||||||||||
| 220 | map { | ||||||||||||||||||||||||||||||||
| 221 | 2 | "$str $_"; | |||||||||||||||||||||||||||||||
| 222 | } split /、/, $koaza_kana; | ||||||||||||||||||||||||||||||||
| 223 | } @subtown_kana; | ||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||
| 226 | 5 | $columns->{town} = $aza; | |||||||||||||||||||||||||||||||
| 227 | 5 | $columns->{town_kana} = $aza_kana; | |||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||
| 229 | # other | ||||||||||||||||||||||||||||||||
| 230 | elsif ($columns->{town} =~ s/((.+?))$//) { | ||||||||||||||||||||||||||||||||
| 231 | 33 | my $town = $1; | |||||||||||||||||||||||||||||||
| 232 | 33 | $town =~ s{「([^\」]+)」}{ | |||||||||||||||||||||||||||||||
| 233 | 6 | my $str = $1; | |||||||||||||||||||||||||||||||
| 234 | 6 | $str =~ s/、/_____COMMNA_____/g; | |||||||||||||||||||||||||||||||
| 235 | 6 | "「${str}」"; | |||||||||||||||||||||||||||||||
| 236 | }ge; | ||||||||||||||||||||||||||||||||
| 237 | @subtown = map { | ||||||||||||||||||||||||||||||||
| 238 | 33 | my $str = $_; | |||||||||||||||||||||||||||||||
| 239 | 102 | $str =~ s/_____COMMNA_____/、/g; | |||||||||||||||||||||||||||||||
| 240 | 102 | $str; | |||||||||||||||||||||||||||||||
| 241 | } split /、/, $town; | ||||||||||||||||||||||||||||||||
| 242 | 33 | ▶ | if ($columns->{town_kana} =~ s/\((.+?)\)$//) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 243 | 32 | my $kana = $1; | |||||||||||||||||||||||||||||||
| 244 | 32 | $kana =~ s{<([^>]+)>}{ | |||||||||||||||||||||||||||||||
| 245 | 5 | my $str = $1; | |||||||||||||||||||||||||||||||
| 246 | 5 | $str =~ s/、/_____COMMNA_____/g; | |||||||||||||||||||||||||||||||
| 247 | 5 | "<${str}>"; | |||||||||||||||||||||||||||||||
| 248 | }ge; | ||||||||||||||||||||||||||||||||
| 249 | @subtown_kana = map { | ||||||||||||||||||||||||||||||||
| 250 | 32 | my $str = $_; | |||||||||||||||||||||||||||||||
| 251 | 94 | $str =~ s/_____COMMNA_____/,/g; | |||||||||||||||||||||||||||||||
| 252 | 94 | $str; | |||||||||||||||||||||||||||||||
| 253 | } split /、/, $kana; | ||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||
| 257 | 62 | ▶ | if (@subtown) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 258 | 43 | $columns->{subtown} = \@subtown; | |||||||||||||||||||||||||||||||
| 259 | 43 | $columns->{subtown_kana} = \@subtown_kana; | |||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | 75 | ▶ | sub fix_build { | ||||||||||||||||||||||||||||||
|
Subroutine
fix_build: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 264 | 75 | my $self = shift; | |||||||||||||||||||||||||||||||
| 265 | 75 | my $columns = $self->{columns}; | |||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||
| 267 | 75 | ▶ | unless ($self->{build_town}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 268 | 68 | ▶ | unless ($columns->{town} && $columns->{town} =~ /(.+?階.*?)$/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$columns->{"town"} and $columns->{"town"} =~ /\x{ff08}.+?\x{968e}.*?\x{ff09}$/
MC/DC100%2/2
$columns->{"town"} and $columns->{"town"} =~ /\x{ff08}.+?\x{968e}.*?\x{ff09}$/
$columns->{"town"}
$columns->{"town"} =~ /\x{ff08}.+?\x{968e}.*?\x{ff09}$/
Truth table100%3/3
A and B
A= $columns->{"town"}B= $columns->{"town"} =~ /\x{ff08}.+?\x{968e}.*?\x{ff09}$/
| |||||||||||||||||||||||||||||||||
| 269 | 65 | return; | |||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||
| 273 | 10 | my $build_town = $self->{build_town}; | |||||||||||||||||||||||||||||||
| 274 | 10 | my $build_town_kana = $self->{build_town_kana}; | |||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||
| 276 | 10 | $columns->{town} =~ s/(高層棟)//; | |||||||||||||||||||||||||||||||
| 277 | 10 | $columns->{town_kana} =~ s/\(コウソウトウ\)//; | |||||||||||||||||||||||||||||||
| 278 | 10 | ▶ | if ($columns->{town} =~ s/(次のビルを除く)$//) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 279 | 1 | $columns->{town_kana} =~ s/\(ツギノビルヲノゾク\)$//; | |||||||||||||||||||||||||||||||
| 280 | } elsif ($columns->{town} =~ /^\Q$build_town\E(.+)((.+))$/) { | ||||||||||||||||||||||||||||||||
| 281 | 8 | my $floor = $2; | |||||||||||||||||||||||||||||||
| 282 | 8 | $columns->{build} = $1; | |||||||||||||||||||||||||||||||
| 283 | 8 | ▶ | if ($floor =~ /(\d+)階/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 284 | 6 | $columns->{floor} = alnum_z2h($1); | |||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||
| 287 | 8 | $columns->{town_kana} =~ /^\Q$build_town_kana\E(.+)\(.+$/; | |||||||||||||||||||||||||||||||
| 288 | 8 | $columns->{build_kana} = $1; | |||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||
| 290 | 8 | $columns->{town} = $build_town; | |||||||||||||||||||||||||||||||
| 291 | 8 | $columns->{town_kana} = $build_town_kana; | |||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||
| 295 | 75 | ▶ | sub fix_kana_alnum { | ||||||||||||||||||||||||||||||
|
Subroutine
fix_kana_alnum: called CC=14 SCAR=26.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 296 | 75 | my $self = shift; | |||||||||||||||||||||||||||||||
| 297 | 75 | ▶ | return unless $self->{katakana_h2z} || $self->{alnum_z2h}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"katakana_h2z"} or $self->{"alnum_z2h"}
MC/DC100%2/2
$self->{"katakana_h2z"} or $self->{"alnum_z2h"}
$self->{"katakana_h2z"}
$self->{"alnum_z2h"}
Truth table100%3/3
A or B
A= $self->{"katakana_h2z"}B= $self->{"alnum_z2h"}
| |||||||||||||||||||||||||||||||||
| 298 | 74 | for my $name (qw/ pref_kana region_kana district_kana city_kana ward_kana town_kana build_kana pref region district city ward town build /) { | |||||||||||||||||||||||||||||||
| 299 | 1036 | ▶ | next unless defined $self->{columns}{$name}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 300 | 682 | ▶ | $self->{columns}{$name} = katakana_h2z($self->{columns}{$name}) if $self->{katakana_h2z}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 301 | 682 | ▶ | $self->{columns}{$name} = alnum_z2h($self->{columns}{$name}) if $self->{alnum_z2h}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||
| 303 | 74 | ▶ | if ($self->has_subtown) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 304 | 43 | for my $i (0..(scalar(@{ $self->subtown }) - 1)) { | |||||||||||||||||||||||||||||||
| 305 | 158 | ▶ | $self->subtown->[$i] = katakana_h2z($self->subtown->[$i]) if $self->{katakana_h2z}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 306 | 158 | ▶ | $self->subtown->[$i] = alnum_z2h($self->subtown->[$i]) if $self->{alnum_z2h}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||
| 308 | 43 | for my $i (0..(scalar(@{ $self->subtown_kana }) - 1)) { | |||||||||||||||||||||||||||||||
| 309 | 150 | ▶ | $self->subtown_kana->[$i] = katakana_h2z($self->subtown_kana->[$i]) if $self->{katakana_h2z}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 310 | 150 | ▶ | $self->subtown_kana->[$i] = alnum_z2h($self->subtown_kana->[$i]) if $self->{alnum_z2h}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||
| 315 | 16 | 1; | |||||||||||||||||||||||||||||||
| 316 | __END__ | ||||||||||||||||||||||||||||||||