| 1 | package Treex::Block::Read::Sentences; | ||||||||||||||||||||||||||||
| 2 | 1 | $Treex::Block::Read::Sentences::VERSION = '2.20151210'; | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Treex::Core::Common; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | extends 'Treex::Block::Read::BaseTextReader'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | has 'skip_empty' => (is => 'ro', isa => 'Bool', default => 0); | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | sub next_document { | ||||||||||||||||||||||||||||
| 10 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
next_document: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 11 | 0 | my $text = $self->next_document_text(); | |||||||||||||||||||||||||||
| 12 | 0 | ▶ | return if !defined $text; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 0 | my $document = $self->new_document(); | |||||||||||||||||||||||||||
| 15 | 0 | foreach my $sentence ( split /\n/, $text ) { | |||||||||||||||||||||||||||
| 16 | 0 | ▶ | next if ($sentence eq '' and $self->skip_empty); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sentence eq "" and $self->skip_empty
MC/DC0%0/2
$sentence eq "" and $self->skip_empty
$sentence eq ""
$self->skip_empty
Truth table0%0/3
A and B
A= $sentence eq ""B= $self->skip_empty
| |||||||||||||||||||||||||||||
| 17 | 0 | my $bundle = $document->create_bundle(); | |||||||||||||||||||||||||||
| 18 | 0 | my $zone = $bundle->create_zone( $self->language, $self->selector ); | |||||||||||||||||||||||||||
| 19 | 0 | $zone->set_sentence($sentence); | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | return $document; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | 1; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | __END__ | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =pod | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | =head1 NAME | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | Treex::Block::Read::Sentences | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =head1 VERSION | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | version 2.20151210 | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | Read::Sentences from='!dir*/file*.txt' skip_empty=1 | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | Document reader for plain text format, one sentence per line. | ||||||||||||||||||||||||||||
| 48 | The sentences are stored into L<bundles|Treex::Core::Bundle> in the | ||||||||||||||||||||||||||||
| 49 | L<document|Treex::Core::Document>. | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =over | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =item from | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | space or comma separated list of filenames | ||||||||||||||||||||||||||||
| 58 | See L<Treex::Core::Files> for full syntax. | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =item skip_empty | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | If set to 1, ignore empty lines (don't create empty sentences). | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =back | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =head1 METHODS | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =over | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =item next_document | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | Loads a document. | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =back | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =head1 SEE | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | L<Treex::Block::Read::BaseTextReader> | ||||||||||||||||||||||||||||
| 79 | L<Treex::Core::Document> | ||||||||||||||||||||||||||||
| 80 | L<Treex::Core::Bundle> | ||||||||||||||||||||||||||||
| 81 | L<Treex::Block::Read::AlignedSentences> | ||||||||||||||||||||||||||||
| 82 | L<Treex::Block::Read::SentencesTSV> | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | Martin Popel | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||