NewsExtractor/SiteSpecificExtractor/news_cts_com_tw.pm

filter: Statementstmt 30.5% 11 / 36 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 4 totaltotal 23.7% 14 / 59 CC 8 SCAR 26.0
CC
8
Cov
23%
journalist
30.0
headline
6.0
content_text
6.0
CRAP 13.5
« NewsExtractor/SiteSpecificExtractor/newnet_tw.pm ↑ Summary NewsExtractor/Role/ContentTextExtractor.pm »
1 package NewsExtractor::SiteSpecificExtractor::news_cts_com_tw;
2 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 extends 'NewsExtractor::SiteSpecificExtractor';
5  
6 1 ▶use Importer 'NewsExtractor::TextUtil' => qw< html2text normalize_whitespace >;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub headline {
Subroutine headline: not called CC=2 SCAR=17.9
Pod undocumented
9 0 my ($self) = @_;
10 0 ▶ if (my $el = $self->dom->at('h1[itemprop="headline"]')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $el = $self->dom->at("h1[itemprop=\"headline\"]")) 0 0 0
11 0 return $el->all_text;
12 }
13 0 return undef;
14 }
15  
16 0 ▶sub content_text {
Subroutine content_text: not called CC=2 SCAR=17.9
Pod undocumented
17 0 my ($self) = @_;
18 0 ▶ if (my $el = $self->dom->at('div[itemprop="articleBody"]')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $el = $self->dom->at("div[itemprop=\"articleBody\"]")) 0 0 0
19 0 return html2text( $el->to_string );
20 }
21 0 return undef;
22 }
23  
24 0 ▶sub dateline {
Subroutine dateline: not called CC=2 SCAR=17.9
Pod undocumented
25 0 my ($self) = @_;
26 0 ▶ if (my $el = $self->dom->at('p[itemprop="datePublished"]')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $el = $self->dom->at("p[itemprop=\"datePublished\"]")) 0 0 0
27 0 return $el->attr("datetime");
28 }
29 0 return undef;
30 }
31  
32 0 ▶sub journalist {
Subroutine journalist: not called CC=5 SCAR=34.0
Pod undocumented
33 0 my ($self) = @_;
34  
35  
36 0 ▶ if (my $el = $self->dom->at("div.artical-content")) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $el = $self->dom->at("div.artical-content")) 0 0 0
37 0 my $p_first = $el->at("p");
38 0 my $line = $p_first->all_text;
39 0 ▶ if ($line =~ m{([\p{Letter}\p{Space}])報導\s*/\s*\p{Letter}{1,5}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ m[([\p{Letter}\p{Space}])\x{5831}\x{5c0e}\s*/\s*\p{Letter}{1,5}]) 0 0 0
40 0 return normalize_whitespace($line);
41 }
42 }
43  
44 0 my @patterns = (
45 qr{^(.+?\s*報導\s*/\s*\S+)\s?\n},
46 qr<\A (\p{Letter}+? \s+ 採訪/撰稿 \s+ \p{Letter}+? \s+ 攝影/剪輯) \s+ />x,
47 );
48  
49 0 my $content_text = $self->content_text;
50 0 my @matched;
51 0 for my $pat (@patterns) {
52 0 @matched = $content_text =~ m/$pat/;
53 0 ▶ last if @matched;
Branch: 1 branch
BranchTrueFalseTotal
if @matched 0 0 0
54 }
55  
56 0 return $matched[0];
57 }
58  
59 1 1;
« NewsExtractor/SiteSpecificExtractor/newnet_tw.pm ↑ Summary NewsExtractor/Role/ContentTextExtractor.pm »