| 1 | package Treex::Block::W2A::CS::Tokenize; | ||
| 2 | 1 | $Treex::Block::W2A::CS::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 | |||
| 13 | 0 | my ( $self, $sentence ) = @_; | |
| 14 | |||
| 15 | 0 | $sentence = super(); | |
| 16 | |||
| 17 | # pad with spaces for easier regexps | ||
| 18 | 0 | $sentence =~ s/^(.*)$/ $1 /; | |
| 19 | |||
| 20 | # Czech conditional enclitic "-li" should be treated as a separate token | ||
| 21 | 0 | $sentence =~ s/ (\p{Letter}+)-(li|LI) / $1 - $2 /g; | |
| 22 | |||
| 23 | # Number ranges are considered 3 tokens in PDT (and thus learned to be treated so by parsers) | ||
| 24 | 0 | $sentence =~ s/([0-9])\-([0-9])/$1 - $2/g; | |
| 25 | |||
| 26 | # clean out extra spaces | ||
| 27 | 0 | $sentence =~ s/^\s*//g; | |
| 28 | 0 | $sentence =~ s/\s*$//g; | |
| 29 | |||
| 30 | 0 | return $sentence; | |
| 31 | 1 | }; | |
| 32 | |||
| 33 | 1 | 1; | |
| 34 | |||
| 35 | __END__ | ||