| 1 | package Wiktionary::Parser::Section::Classifications; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use Wiktionary::Parser::Section; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 3 | ▶ | use base qw(Wiktionary::Parser::Section); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 8 | 0 | my $class = shift; | |||||||||||||||||||
| 9 | 0 | my %args = @_; | |||||||||||||||||||
| 10 | 0 | my $self = bless Wiktionary::Parser::Section->new(%args), $class; | |||||||||||||||||||
| 11 | 0 | return $self; | |||||||||||||||||||
| 12 | } | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | # add a line of content to this section and parse it into its component parts | ||||||||||||||||||||
| 17 | 0 | ▶ | sub add_content { | ||||||||||||||||||
|
Subroutine
add_content: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||
| 18 | 0 | my $self = shift; | |||||||||||||||||||
| 19 | 0 | my $line = shift; | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | # * {{sense|swindler}} [[swindler]], [[cheat]] | ||||||||||||||||||||
| 22 | # * {{l|en|blee}} | ||||||||||||||||||||
| 23 | # * {{l|pt|para|gloss=[[to]], [[for]]}} | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 0 | ▶ | my $language = $self->get_language() || ''; | ||||||||||||||||||
|
Condition0%0/2
$self->get_language || ''
MC/DC0%0/1
$self->get_language || ''
$self->get_language
Truth table0%0/2
A
A= $self->get_language
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | ▶ | if ($line =~ m/^\*\s\{\{([^\}]+)\}\}/) { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 28 | 0 | my $meta = $1; | |||||||||||||||||||
| 29 | 0 | my @meta_parts = split(/\|/,$meta); | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 0 | my @lexemes = $line =~ m/\[\[([^\]]+)\]\]/g; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 0 | ▶ | if ($meta_parts[0] =~ m/sense/i) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 34 | 0 | $self->add_group( | |||||||||||||||||||
| 35 | sense => $meta_parts[1], | ||||||||||||||||||||
| 36 | language => $language, | ||||||||||||||||||||
| 37 | lexemes => \@lexemes, | ||||||||||||||||||||
| 38 | ) | ||||||||||||||||||||
| 39 | } elsif ($meta_parts[0] =~ m/^l$/) { | ||||||||||||||||||||
| 40 | 0 | my @lexemes; | |||||||||||||||||||
| 41 | 0 | push @lexemes, $meta_parts[2]; | |||||||||||||||||||
| 42 | 0 | push @lexemes, $line =~ m/\[\[([^\]]+)\]\]/g; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | $self->add_group( | ||||||||||||||||||
|
Condition0%0/3
$language || $meta_parts[1]
MC/DC0%0/2
$language || $meta_parts[1]
$language
$meta_parts[1]
Truth table0%0/3
A || B
A= $languageB= $meta_parts[1]
| |||||||||||||||||||||
| 45 | sense => $self->get_document()->get_title(), | ||||||||||||||||||||
| 46 | language => $language || $meta_parts[1], | ||||||||||||||||||||
| 47 | lexemes => \@lexemes, | ||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | # (''in the future''): [[backward]], [[backwards]], into the [[past]] | ||||||||||||||||||||
| 51 | } elsif ($line =~ m/\(\'+([^\']+)\'+\)/) { | ||||||||||||||||||||
| 52 | 0 | my $sense = $1; | |||||||||||||||||||
| 53 | 0 | my @lexemes = $line =~ m/\[\[([^\]]+)\]\]/g; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 0 | $self->add_group( | |||||||||||||||||||
| 56 | sense => $sense, | ||||||||||||||||||||
| 57 | language => $language, | ||||||||||||||||||||
| 58 | lexemes => \@lexemes, | ||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | } elsif ($line =~ m/Wikisaurus/) { | ||||||||||||||||||||
| 62 | # add wikisaurus tags (e.g. Wikisaurus:cat) | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 0 | my @links = $line =~ m/\[\[([^\]]+)\]\]/g; | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 0 | for my $link (@links) { | |||||||||||||||||||
| 67 | 0 | my ($ws,$token) = split(/:/,$link); | |||||||||||||||||||
| 68 | 0 | $self->add_group( | |||||||||||||||||||
| 69 | sense => $token, | ||||||||||||||||||||
| 70 | language => $language, | ||||||||||||||||||||
| 71 | lexemes => [$link], | ||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | } else { | ||||||||||||||||||||
| 76 | 0 | my @lexemes = $line =~ m/\[\[([^\]]+)\]\]/g; | |||||||||||||||||||
| 77 | 0 | $self->add_group( | |||||||||||||||||||
| 78 | sense => $self->get_document()->get_title(), | ||||||||||||||||||||
| 79 | language => $language, | ||||||||||||||||||||
| 80 | lexemes => \@lexemes, | ||||||||||||||||||||
| 81 | ) | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 0 | push @{$self->{content}}, $line; | |||||||||||||||||||
| 86 | } | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | ▶ | sub add_group { | ||||||||||||||||||
|
Subroutine
add_group: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 89 | 0 | my $self = shift; | |||||||||||||||||||
| 90 | 0 | my %args = @_; | |||||||||||||||||||
| 91 | 0 | my $language = $args{language}; | |||||||||||||||||||
| 92 | 0 | my $sense = $args{sense}; | |||||||||||||||||||
| 93 | 0 | my $lexemes = $args{lexemes}; | |||||||||||||||||||
| 94 | 0 | push @{$self->{groups}}, { | |||||||||||||||||||
| 95 | sense => $sense, | ||||||||||||||||||||
| 96 | language => $language, | ||||||||||||||||||||
| 97 | lexemes => $lexemes, | ||||||||||||||||||||
| 98 | }; | ||||||||||||||||||||
| 99 | } | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | 0 | ▶ | sub get_groups { | ||||||||||||||||||
|
Subroutine
get_groups: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 102 | 0 | my $self = shift; | |||||||||||||||||||
| 103 | 0 | return $self->{groups}; | |||||||||||||||||||
| 104 | } | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | 3 | 1; | |||||||||||||||||||