line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
19
|
|
101
|
use strict; |
|
19
|
|
|
|
|
40
|
|
|
19
|
|
|
|
|
587
|
|
30
|
19
|
|
|
19
|
|
98
|
use warnings; |
|
19
|
|
|
|
|
40
|
|
|
19
|
|
|
|
|
480
|
|
31
|
|
|
|
|
|
|
|
32
|
19
|
|
|
19
|
|
94
|
use base 'Class::Accessor::Fast'; |
|
19
|
|
|
|
|
36
|
|
|
19
|
|
|
|
|
3814
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__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
|
|
|
|
|
|
|
sub new { |
49
|
143990
|
|
|
143990
|
1
|
432041
|
my ($class, %args) = @_; |
50
|
143990
|
|
50
|
|
|
569116
|
$args{type} ||= "word"; |
51
|
143990
|
|
|
|
|
840315
|
$class->SUPER::new({%args}); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |