| 1 | ## -*- Mode: CPerl -*- | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## File: DTA::CAB::Token.pm | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Author: Bryan Jurish <moocow@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Description: generic API for tokens passed to/from DTA::CAB::Analyzer | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | package DTA::CAB::Token; | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use DTA::CAB::Datum; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | ## Globals | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | our @ISA = qw(DTA::CAB::Datum); | |||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ## Constructors etc. | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ## $tok = CLASS_OR_OBJ->new($text) | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ## $tok = CLASS_OR_OBJ->new($text,%args) | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ## $tok = CLASS_OR_OBJ->new(%args) | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ## + object structure: HASH | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ## { | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ## ##-- Required Attributes | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ## text => $raw_text, ##-- raw token text | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ## ##-- Optional Attributes | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ## _attrs => \%attrs, ##-- scalar attributes ($key=>$val, e.g. for xml pass-through) | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ## _dtrs => \@dtrs, ##-- structural daughters (DTA::CAB::Datum objects, e.g. for xml pass-through) | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ## $key => $value, ##-- perl-level structure (e.g. analyzer output) | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ## ## | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ## ##-- DTA::CAB Attributes (post-analysis) | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ## #loc => {off=>$offset, len=>$len}, ##-- parsed & passed through by some formats | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ## #xlit => $a_xlit, ##-- analysis output by DTA::CAB::Analyzer::Transliterator | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ## #morph => $a_morph, ##-- analysis output by DTA::CAB::Analyzer::Morph subclass for literal morphology lookup | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ## #safe => $a_safe, ##-- analysis output by DTA::CAB::Analyzer::MorphSafe (?) | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ## #rw => $a_rw, ##-- analysis output by DTA::CAB::Analyzer::Rewrite subclass for rewrite lookup | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ## } | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | return bless({ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
@_ < 2 or @_ % 2 != 0
ref $_[0] || $_[0]
MC/DC0%0/2
@_ < 2 or @_ % 2 != 0
@_ < 2
@_ % 2 != 0
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table0%0/3
A or B
A= @_ < 2B= @_ % 2 != 0
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ((@_ < 2 || @_ % 2 != 0) | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ? @_[1..$#_] | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | : (text=>$_[1],@_[2..$#_])) | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ref($_[0]) || $_[0]); | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ## Methods: Formatting : OBSOLETE! | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | 1; ##-- be happy | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||