| 1 | package Treex::Tool::EnglishMorpho::Lemmatizer; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | $Treex::Tool::EnglishMorpho::Lemmatizer::VERSION = '2.20151102'; | |||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Treex::Core::Common; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Treex::Core::Resource qw(require_file_from_share); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use File::Slurp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | has 'exceptions_filename' => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | return require_file_from_share('data/models/lemmatizer/en/exceptions2014_11_21.tsv'); | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | has 'negation_filename' => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | return require_file_from_share('data/models/lemmatizer/en/negation'); | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | has 'exceptions' => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | builder => '_build_exceptions', | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | has 'negation' => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | builder => '_build_negation', | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | init_arg => undef, | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | has 'cut_negation' => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | default => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | reader => 'cut_negation', | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 3 | has 'lowercase_proper_names' => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | reader => 'lowercase_proper_names', | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | my $V = qr/[aeiou]/; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | my $VY = qr/[aeiouy]/; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | my $C = qr/[bcdfghjklmnpqrstvwxyz]/; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 3 | my $CXY = qr/[bcdfghjklmnpqrstvwxz]/; | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | my $S = qr/([sxz]|[cs]h)/; | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | my $S2 = qr/(ss|zz)/; | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | my $PRE = qr/(be|ex|in|mis|pre|pro|re)/; | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | #The most importat sub: | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | #Input: word form and POS tag (Penn style) | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | #Output: lemma and was_negative_prefix | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | ▶ | sub lemmatize { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lemmatize: called CC=6 SCAR=21.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | my ( $self, $word, $tag ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | my $negative_prefix = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | if ( ( $tag !~ /^NNP/ || $self->lowercase_proper_names ) && $word ne 'I' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
!($tag =~ /^NNP/) || $self->lowercase_proper_names and $word ne "I"
not $tag =~ /^NNP/ or $self->lowercase_proper_names
MC/DC0%0/3
!($tag =~ /^NNP/) || $self->lowercase_proper_names and $word ne "I"
not $tag =~ /^NNP/
$self->lowercase_proper_names
$word ne "I"
Truth table20%1/5
not(A) or B and C
A= not $tag =~ /^NNP/B= $self->lowercase_proper_namesC= $word ne "I"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $word = lc $word; | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | my $entry = $self->exceptions->{$tag}{$word}; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | if ($entry) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return @$entry; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | if ( $self->cut_negation ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ( $word, $negative_prefix ) = $self->_cut_negative_prefix( $word, $tag ); | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | return ( $self->_lemmatize_by_rules( $word, $tag ), $negative_prefix ); | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | ▶ | sub _cut_negative_prefix { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cut_negative_prefix: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | my ( $self, $word, $tag ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # We are interested only in adjectives, adverbs and nouns. | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # English verbs are negated usually by "not" (don't,...). | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # Proper nouns (NNP,NNPS) are also left unchanged (Disney, Intel, Irvin... Non-IBM). | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | if ( $tag =~ /^(J.*|R.*|NN|NNS)$/ and $word =~ $self->negation ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tag =~ /^(J.*|R.*|NN|NNS)$/ and $word =~ $self->negation
MC/DC0%0/2
$tag =~ /^(J.*|R.*|NN|NNS)$/ and $word =~ $self->negation
$tag =~ /^(J.*|R.*|NN|NNS)$/
$word =~ $self->negation
Truth table33%1/3
A and B
A= $tag =~ /^(J.*|R.*|NN|NNS)$/B= $word =~ $self->negation
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $word =~ s/^(un|in|im|non-?|dis-?|il|ir)//; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | return ( $word, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | return ( $word, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub _lemmatize_NNS_NNPS { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lemmatize_NNS_NNPS: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my ( $self, $word ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | return $word if $word =~ s/men$/man/; #over 600 words (in BNC) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | return $word if $word =~ s/shoes$/shoe/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | return $word if $word =~ s/wives$/wife/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | return $word if $word =~ s/(${C}us)es$/$1/; #buses bonuses | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | return $word if $word =~ s/(${V}se)s$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | return $word if $word =~ s/(.${CXY}z)es$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | return $word if $word =~ s/(${VY}ze)s$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | return $word if $word =~ s/($S2)es$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return $word if $word =~ s/(.${V}rse)s$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | return $word if $word =~ s/onses$/onse/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | return $word if $word =~ s/($S)es$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | return $word if $word =~ s/(.$C)ies$/$1y/; #ponies vs ties | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | return $word if $word =~ s/(${CXY}o)es$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | return $word if $word =~ s/s$//; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | return $word; | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub _lemmatize_VBG { ## no critic (Subroutines::ProhibitExcessComplexity) this is complex | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lemmatize_VBG: not called CC=34 SCAR=70.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my ( $self, $word ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | return $word if $word =~ s/(${CXY}z)ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | return $word if $word =~ s/(${VY}z)ing$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | return $word if $word =~ s/($S2)ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | return $word if $word =~ s/($C${V}ll)ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | return $word if $word =~ s/($C${V}($CXY)\2)ing$/$1/; #cancel-ling vs call-ing - exception is needed | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | return $word if $word =~ s/^($CXY)ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | return $word if $word =~ s/^($PRE*$C${V}ng)ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | return $word if $word =~ s/icking$/ick/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return $word if $word =~ s/(${C}in)ing$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | return $word if $word =~ s/($C$V[npwx])ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | return $word if $word =~ s/(qu$V${C})ing$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | return $word if $word =~ s/(u${V}d)ing$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | return $word if $word =~ s/(${C}let)ing$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | return $word if $word =~ s/^($PRE*$C+[ei]t)ing$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | return $word if $word =~ s/([ei]t)ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | return $word if $word =~ s/($PRE$CXY${CXY}eat)ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | return $word if $word =~ s/($V$CXY${CXY}eat)ing$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | return $word if $word =~ s/(.[eo]at)ing$/$1/; #treating vs creating | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | return $word if $word =~ s/(.${V}at)ing$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | return $word if $word =~ s/($V$V[cgsv])ing$/$1e/; #announcing increasing | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return $word if $word =~ s/($V$V$C)ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | return $word if $word =~ s/(.[rw]l)ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | return $word if $word =~ s/(.th)ing$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | return $word if $word =~ s/($CXY[cglsv])ing$/$1e/; #involving | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | return $word if $word =~ s/($CXY$CXY)ing$/$1/; #reporting | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | return $word if $word =~ s/uing$/ue/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | return $word if $word =~ s/($VY$VY)ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | return $word if $word =~ s/ying$/y/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | return $word if $word =~ s/(${CXY}o)ing$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | return $word if $word =~ s/^($PRE*$C+or)ing$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | return $word if $word =~ s/($C[clt]or)ing$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | return $word if $word =~ s/([eo]r)ing$/$1/; #offering | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | return $word if $word =~ s/ing$/e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return $word; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub _lemmatize_VBD_VBN { ## no critic (Subroutines::ProhibitExcessComplexity) this is complex | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lemmatize_VBD_VBN: not called CC=33 SCAR=70.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my ( $self, $word ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | return $word if $word =~ s/en$/e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | return $word if $word =~ s/(${CXY}z)ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | return $word if $word =~ s/(${VY}z)ed$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | return $word if $word =~ s/($S2)ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | return $word if $word =~ s/($C${V}ll)ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | return $word if $word =~ s/($C${V}($CXY)\2)ed$/$1/; #cancel-led vs call-ed - wordlist is needed | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | return $word if $word =~ s/^($CXY)ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | return $word if $word =~ s/^($PRE*$C${V}ng)ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | return $word if $word =~ s/icked$/ick/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | return $word if $word =~ s/(${C}(in|[clnt]or))ed$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | return $word if $word =~ s/($C$V[npwx])ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | return $word if $word =~ s/^($PRE*$C+or)ed$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | return $word if $word =~ s/([eo]r)ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | return $word if $word =~ s/(${C})ied$/$1y/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | return $word if $word =~ s/(qu$V${C})ed$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | return $word if $word =~ s/(u${V}d)ed$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | return $word if $word =~ s/(${C}let)ed$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | return $word if $word =~ s/^($PRE*$C+[ei]t)ed$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | return $word if $word =~ s/([ei]t)ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | return $word if $word =~ s/($PRE$CXY${CXY}eat)ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | return $word if $word =~ s/($V$CXY${CXY}eat)ed$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | return $word if $word =~ s/(.[eo]at)ed$/$1/; #treated vs created | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | return $word if $word =~ s/(.${V}at)ed$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | return $word if $word =~ s/($V$V[cgsv])ed$/$1e/; #announced | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | return $word if $word =~ s/($V$V$C)ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | return $word if $word =~ s/(.[rw]l)ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | return $word if $word =~ s/(.th)ed$/$1e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | return $word if $word =~ s/ued$/ue/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | return $word if $word =~ s/($CXY[cglsv])ed$/$1e/; #involved | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | return $word if $word =~ s/($CXY$CXY)ed$/$1/; #reported | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | return $word if $word =~ s/($VY$VY)ed$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | return $word if $word =~ s/ed$/e/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return $word; | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | sub _lemmatize_VBZ { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lemmatize_VBZ: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my ( $self, $word ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | return $word if $word =~ s/(${V}se)s$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | return $word if $word =~ s/(.${CXY}z)es$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | return $word if $word =~ s/(${VY}ze)s$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | return $word if $word =~ s/($S2)es$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | return $word if $word =~ s/(.${V}rse)s$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | return $word if $word =~ s/onses$/onse/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | return $word if $word =~ s/($S)es$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | return $word if $word =~ s/(.$C)ies$/$1y/; #tries, relies vs lies | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | return $word if $word =~ s/(${CXY}o)es$/$1/; #does, undergoes | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | return $word if $word =~ s/(.)s$/$1/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | return $word; | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | sub _lemmatize_JJR_RBR { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lemmatize_JJR_RBR: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my ( $self, $word ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | return $word if $word =~ s/([^e]ll)er$/$1/; #smaller | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | return $word if $word =~ s/($C)\1er$/$1/; #bigger | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | return $word if $word =~ s/ier$/y/; #earlier | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | return $word if $word =~ s/($V$V$C)er$/$1/; #weaker | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | return $word if $word =~ s/($C$V[npwx])er$/$1/; #lower | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | return $word if $word =~ s/($V$C)er$/$1e/; #nicer wider | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | return $word if $word =~ s/([bcdfghjklmpqrstvwxz][cglsv])er$/$1e/; #larger,stranger vs stronger, younger | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | return $word if $word =~ s/([ue])er$/$1e/; #freer | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | return $word if $word =~ s/er$//; #harder | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return $word; | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | sub _lemmatize_JJS_RBS { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lemmatize_JJS_RBS: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my ( $self, $word ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | return $word if $word =~ s/([^e]ll)est$/$1/; #smallest | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | return $word if $word =~ s/(.)\1est$/$1/; #biggest | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | return $word if $word =~ s/iest$/y/; #earliest | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | return $word if $word =~ s/($V$V$C)est$/$1/; #weakest | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | return $word if $word =~ s/($C$V[npwx])est$/$1/; #lowest | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | return $word if $word =~ s/($V$C)est$/$1e/; #nicest widest | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | return $word if $word =~ s/([bcdfghjklmpqrstvwxz][cglsv])est$/$1e/; #largest vs strongest | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | return $word if $word =~ s/(.{3,})est$/$1/; #hardest | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | return $word; | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | ▶ | sub _lemmatize_by_rules { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lemmatize_by_rules: called CC=8 SCAR=24.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | my ( $self, $word, $tag ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | ▶ | my $lemma = $tag =~ /NNP?S/ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | ? $self->_lemmatize_NNS_NNPS($word) | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | : $tag =~ /^VBG/ ? $self->_lemmatize_VBG($word) | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | : $tag =~ /VB[DN]/ ? $self->_lemmatize_VBD_VBN($word) | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | : $tag eq 'VBZ' ? $self->_lemmatize_VBZ($word) | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | : $tag =~ /JJR|RBR/ ? $self->_lemmatize_JJR_RBR($word) | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | : $tag =~ /JJS|RBS/ ? $self->_lemmatize_JJS_RBS($word) | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | : $word | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | ; | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | ▶ | return $word if $lemma eq ''; # Otherwise e.g. "est"->"" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | return $lemma; | |||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | ▶ | sub _build_exceptions { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_exceptions: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | my %exceptions; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | log_debug( $self->exceptions_filename ); | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | ▶ | open my $ex_file, "<:encoding(utf-8)", $self->exceptions_filename or log_fatal($!); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | ▶ | while (<$ex_file>) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 5610 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||
| 260 | 5610 | my ( $word, $tag, $lemma, $negative_prefix ) = split /\t/; | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 5610 | ▶ | $negative_prefix = ( defined $negative_prefix and $negative_prefix eq '1' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $negative_prefix && $negative_prefix eq '1'
MC/DC0%0/2
defined $negative_prefix && $negative_prefix eq '1'
defined $negative_prefix
$negative_prefix eq '1'
Truth table33%1/3
A && B
A= defined $negative_prefixB= $negative_prefix eq '1'
| |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 5610 | $exceptions{$tag}{$word} = [ $lemma, $negative_prefix ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | close $ex_file; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | return \%exceptions; | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | sub _build_negation { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_negation: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my $pattern = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my @lines = read_file( $self->negation_filename, binmode => ':encoding(utf-8)', err_mode => 'log_fatal' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # or log_fatal('Cannot load lemmatization exceptions from ' . $self->negation_filename); | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | chomp(@lines); | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $pattern = join '|', @lines; | |||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | #$pattern =~ s/-/\-/g; | ||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $negation = qr/^($pattern)/; | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | return $negation; | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||