| 1 | package Treex::Block::W2A::EN::Tokenize; | ||
| 2 | 1 | $Treex::Block::W2A::EN::Tokenize::VERSION = '2.20151102'; | |
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Treex::Core::Common; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | extends 'Treex::Block::W2A::Tokenize'; | |
| 10 | |||
| 11 | 0 | ▶ | override 'tokenize_sentence' => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 12 | 0 | my ( $self, $sentence ) = @_; | |
| 13 | 0 | $sentence = super(); | |
| 14 | 0 | $sentence =~ s/^(.*)$/ $1 /; | |
| 15 | |||
| 16 | # it's, I'm, we'd, we're, you'll, I've, Peter's | ||
| 17 | 0 | $sentence =~ s/([\'’´])(s|m|d|ll|re|ve|S|M|D|LL|RE|VE)\s/ $1$2 /g; | |
| 18 | |||
| 19 | # don't | ||
| 20 | 0 | $sentence =~ s/(n[\'’´]t\s)/ $1 /g; | |
| 21 | 0 | $sentence =~ s/(N[\'’´]T\s)/ $1 /g; | |
| 22 | |||
| 23 | # cannot, wanna ... | ||
| 24 | 0 | $sentence =~ s/ ([Cc])annot / $1an not /g; | |
| 25 | 0 | $sentence =~ s/ ([Dd])'ye / $1' ye /g; | |
| 26 | 0 | $sentence =~ s/ ([Gg])imme / $1im me /g; | |
| 27 | 0 | $sentence =~ s/ ([Gg])onna / $1on na /g; | |
| 28 | 0 | $sentence =~ s/ ([Gg])otta / $1ot ta /g; | |
| 29 | 0 | $sentence =~ s/ ([Ll])emme / $1em me /g; | |
| 30 | 0 | $sentence =~ s/ ([Mm])ore'n / $1ore 'n /g; | |
| 31 | 0 | $sentence =~ s/ '([Tt])is / '$1 is /g; | |
| 32 | 0 | $sentence =~ s/ '([Tt])was / '$1 was /g; | |
| 33 | 0 | $sentence =~ s/ ([Ww])anna / $1an na /g; | |
| 34 | |||
| 35 | # clean out extra spaces | ||
| 36 | 0 | $sentence =~ s/\s+/ /g; | |
| 37 | 0 | $sentence =~ s/^\s*//g; | |
| 38 | 0 | $sentence =~ s/\s*$//g; | |
| 39 | |||
| 40 | 0 | return $sentence; | |
| 41 | 1 | }; | |
| 42 | |||
| 43 | 1 | 1; | |
| 44 | |||
| 45 | __END__ | ||