| 1 | package Treex::Block::W2A::Segment; | ||
| 2 | 1 | $Treex::Block::W2A::Segment::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 | 1 | extends 'Treex::Block::W2A::SegmentOnNewlines'; | |
| 9 | |||
| 10 | 1 | has use_paragraphs => ( | |
| 11 | is => 'ro', | ||
| 12 | isa => 'Bool', | ||
| 13 | default => 1, | ||
| 14 | documentation => | ||
| 15 | 'Should paragraph boundaries be preserved as sentence boundaries?' | ||
| 16 | . ' Paragraph boundary is defined as two or more consecutive newlines.', | ||
| 17 | ); | ||
| 18 | |||
| 19 | 1 | has use_lines => ( | |
| 20 | is => 'ro', | ||
| 21 | isa => 'Bool', | ||
| 22 | default => 0, | ||
| 23 | documentation => | ||
| 24 | 'Should newlines in the text be preserved as sentence boundaries?' | ||
| 25 | . '(But if you want to detect sentence boundaries just based on newlines' | ||
| 26 | . ' and nothing else, use rather W2A::SegmentOnNewlines.)', | ||
| 27 | ); | ||
| 28 | |||
| 29 | 1 | has limit_words => ( | |
| 30 | is => 'ro', | ||
| 31 | isa => 'Int', | ||
| 32 | default => 250, | ||
| 33 | documentation => | ||
| 34 | 'Should very long segments (longer than the given number of words) be split?' | ||
| 35 | . 'The number of words is only approximate; detected by counting whitespace only,' | ||
| 36 | . 'not by full tokenization. Set to zero to disable this function completely.', | ||
| 37 | ); | ||
| 38 | |||
| 39 | 1 | has detect_lists => ( | |
| 40 | is => 'ro', | ||
| 41 | isa => 'Int', | ||
| 42 | default => 100, | ||
| 43 | documentation => | ||
| 44 | 'Minimum (approx.) number of words to toggle list detection, 0 = never, 1 = always.' | ||
| 45 | ); | ||
| 46 | |||
| 47 | 1 | has segmenter => ( | |
| 48 | is => 'ro', | ||
| 49 | handles => [qw(get_segments)], | ||
| 50 | lazy_build => 1, | ||
| 51 | ); | ||
| 52 | |||
| 53 | 1 | ▶ | use Treex::Tool::Segment::RuleBased; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 54 | |||
| 55 | 0 | ▶ | sub _build_segmenter { |
|
Subroutine
_build_segmenter: not called CC=1 SCAR=6.9
| |||
| 56 | 0 | my $self = shift; | |
| 57 | 0 | return Treex::Tool::Segment::RuleBased->new( | |
| 58 | use_paragraphs => $self->use_paragraphs, | ||
| 59 | use_lines => $self->use_lines, | ||
| 60 | limit_words => $self->limit_words, | ||
| 61 | detect_lists => $self->detect_lists, | ||
| 62 | ); | ||
| 63 | } | ||
| 64 | |||
| 65 | 1 | 1; | |
| 66 | |||
| 67 | __END__ | ||