| 1 | package Treex::Tool::Segment::EN::RuleBased; | ||
| 2 | BEGIN { | ||
| 3 | 1 | ▶ | $Treex::Tool::Segment::EN::RuleBased::VERSION = '0.06903_1'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | } | ||
| 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::Tool::Segment::RuleBased'; | |
| 9 | |||
| 10 | # Note, that we cannot write | ||
| 11 | # sub get_unbreakers { return qr{...}; } | ||
| 12 | # because we want the regex to be compiled just once, not on every method call. | ||
| 13 | 1 | my $UNBREAKERS = qr{ | |
| 14 | \p{Upper} # single uppercase letters (with a rare exception of I) | ||
| 15 | |v|vs|i\.e|rev|e\.g # period-ending items that never indicate sentence breaks | ||
| 16 | |Adj|Adm|Adv|Asst # titles before names of persons, etc. | ||
| 17 | |Bart|Bldg|Brig|Bros|Capt|Cmdr|Col|Comdr|Con|Corp|Cpl|DR|Dr|Drs|Ens|Gen|Gov | ||
| 18 | |Hon|Hr|Hosp|Insp|Lt|MM|MR|MRS|MS|Maj|Messrs|Mlle|Mme|Mr|Mrs|Ms|Msgr|Op|Ord | ||
| 19 | |Pfc|Ph|Prof|Pvt|Rep|Reps|Res|Rev|Rt|Sen|Sens|Sfc|Sgt|Sr|St|Supt|Surg | ||
| 20 | }x; ## no critic (RegularExpressions::ProhibitComplexRegexes) this is nothing complex, just list | ||
| 21 | |||
| 22 | override unbreakers => sub { | ||
| 23 | 0 | ▶ | return $UNBREAKERS; |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 24 | 1 | }; | |
| 25 | |||
| 26 | 1 | 1; | |
| 27 | |||
| 28 | __END__ | ||
| 29 | |||
| 30 | =encoding utf-8 | ||
| 31 | |||
| 32 | =head1 NAME | ||
| 33 | |||
| 34 | Treex::Tool::Segment::EN::RuleBased - rule based sentence segmenter for English | ||
| 35 | |||
| 36 | =head1 VERSION | ||
| 37 | |||
| 38 | =head1 DESCRIPTION | ||
| 39 | |||
| 40 | Sentence boundaries are detected based on a regex rules | ||
| 41 | that detect end-sentence punctuation ([.?!]) followed by a uppercase letter. | ||
| 42 | This class adds a English specific list of "unbreakers", | ||
| 43 | i.e. tokens that usually do not end a sentence | ||
| 44 | even if they are followed by a period and a capital letter. | ||
| 45 | |||
| 46 | See L<Treex::Block::W2A::Segment> | ||
| 47 | |||
| 48 | =head1 AUTHOR | ||
| 49 | |||
| 50 | Martin Popel <popel@ufal.mff.cuni.cz> | ||
| 51 | |||
| 52 | =head1 COPYRIGHT AND LICENSE | ||
| 53 | |||
| 54 | Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague | ||
| 55 | |||
| 56 | This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||
| 57 | |||