| 1 | package Plucene::Analysis::Token; | ||||||||||||
| 2 | |||||||||||||
| 3 | =head1 NAME | ||||||||||||
| 4 | |||||||||||||
| 5 | Plucene::Analysis::Token - A term in a field | ||||||||||||
| 6 | |||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||
| 8 | |||||||||||||
| 9 | =head1 DESCRIPTION | ||||||||||||
| 10 | |||||||||||||
| 11 | A Token is an occurence of a term from the text of a field. It consists of | ||||||||||||
| 12 | a term's text, the start and end offset of the term in the text of the field, | ||||||||||||
| 13 | and a type string. | ||||||||||||
| 14 | |||||||||||||
| 15 | The start and end offsets permit applications to re-associate a token with | ||||||||||||
| 16 | its source text, e.g., to display highlighted query terms in a document | ||||||||||||
| 17 | browser, or to show matching text fragments in a KWIC (KeyWord In Context) | ||||||||||||
| 18 | display, etc. | ||||||||||||
| 19 | |||||||||||||
| 20 | The type is an interned string, assigned by a lexical analyzer | ||||||||||||
| 21 | (a.k.a. tokenizer), naming the lexical or syntactic class that the token | ||||||||||||
| 22 | belongs to. For example an end of sentence marker token might be implemented | ||||||||||||
| 23 | with type "eos". The default token type is "word". | ||||||||||||
| 24 | |||||||||||||
| 25 | =head1 METHODS | ||||||||||||
| 26 | |||||||||||||
| 27 | =cut | ||||||||||||
| 28 | |||||||||||||
| 29 | 19 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 30 | 19 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 31 | |||||||||||||
| 32 | 19 | ▶ | use base 'Class::Accessor::Fast'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 33 | |||||||||||||
| 34 | 19 | __PACKAGE__->mk_accessors(qw[type text start end]); | |||||||||||
| 35 | |||||||||||||
| 36 | =head2 new | ||||||||||||
| 37 | |||||||||||||
| 38 | my $token = Plucene::Analysis::Token->new({ | ||||||||||||
| 39 | type => $type, | ||||||||||||
| 40 | text => $text, | ||||||||||||
| 41 | start => $start, | ||||||||||||
| 42 | end => $end }); | ||||||||||||
| 43 | |||||||||||||
| 44 | This will create a new Plucene::Analysis::Token object. | ||||||||||||
| 45 | |||||||||||||
| 46 | =cut | ||||||||||||
| 47 | |||||||||||||
| 48 | 144010 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||
| 49 | 144010 | my ($class, %args) = @_; | |||||||||||
| 50 | 144010 | ▶ | $args{type} ||= "word"; | ||||||||||
|
Condition50%1/2
$args{"type"} ||= "word"
MC/DC0%0/1
$args{"type"} ||= "word"
$args{"type"}
Truth table50%1/2
A
A= $args{"type"}
| |||||||||||||
| 51 | 144010 | $class->SUPER::new({%args}); | |||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | 19 | 1; | |||||||||||