1Lucy::Analysis::AnalyzeUrs(e3rpmC)ontributed Perl DocumeLnutcayt:i:oAnnalysis::Analyzer(3pm)
2
3
4
6 Lucy::Analysis::Analyzer - Tokenize/modify/filter text.
7
9 # Abstract base class.
10
12 An Analyzer is a filter which processes text, transforming it from one
13 form into another. For instance, an analyzer might break up a long
14 text into smaller pieces (RegexTokenizer), or it might perform case
15 folding to facilitate case-insensitive search (Normalizer).
16
18 new
19 package MyAnalyzer;
20 use base qw( Lucy::Analysis::Analyzer );
21 our %foo;
22 sub new {
23 my $self = shift->SUPER::new;
24 my %args = @_;
25 $foo{$$self} = $args{foo};
26 return $self;
27 }
28
29 Abstract constructor. Takes no arguments.
30
32 transform
33 my $inversion = $analyzer->transform($inversion);
34
35 Take a single Inversion as input and returns an Inversion, either the
36 same one (presumably transformed in some way), or a new one.
37
38 • inversion - An inversion.
39
41 transform_text
42 my $inversion = $analyzer->transform_text($text);
43
44 Kick off an analysis chain, creating an Inversion from string input.
45 The default implementation simply creates an initial Inversion with a
46 single Token, then calls transform(), but occasionally subclasses will
47 provide an optimized implementation which minimizes string copies.
48
49 • text - A string.
50
51 split
52 my $arrayref = $analyzer->split($text);
53
54 Analyze text and return an array of token texts.
55
56 • text - A string.
57
58 dump
59 my $obj = $analyzer->dump();
60
61 Dump the analyzer as hash.
62
63 Subclasses should call dump() on the superclass. The returned object is
64 a hash which should be populated with parameters of the analyzer.
65
66 Returns: A hash containing a description of the analyzer.
67
68 load
69 my $obj = $analyzer->load($dump);
70
71 Reconstruct an analyzer from a dump.
72
73 Subclasses should first call load() on the superclass. The returned
74 object is an analyzer which should be reconstructed by setting the
75 dumped parameters from the hash contained in "dump".
76
77 Note that the invocant analyzer is unused.
78
79 • dump - A hash.
80
81 Returns: An analyzer.
82
84 Lucy::Analysis::Analyzer isa Clownfish::Obj.
85
86
87
88perl v5.38.0 2023-07-20 Lucy::Analysis::Analyzer(3pm)