README
1NAME
2 Text::Query - Query processing framework
3
4SYNOPSIS
5 use Text::Query;
6
7 # Constructor
8 $query = Text::Query->new([QSTRING] [OPTIONS]);
9
10 # Methods
11 $query->prepare(QSTRING [OPTIONS]);
12 $query->match([TARGET]);
13 $query->matchscalar([TARGET]);
14
15DESCRIPTION
16 This module provides an object that matches a data source against a
17 query expression.
18
19 Query expressions are compiled into an internal form when a new object
20 is created or the "prepare" method is called; they are not recompiled on
21 each match.
22
23 The class provided by this module uses four packages to process the
24 query. The query parser parses the question and calls a query expression
25 builder (internal form of the question). The optimizer is then called to
26 reduce the complexity of the expression. The solver applies the
27 expression on a data source.
28
29 The following parsers are provided:
30
31 Text::Query::ParseAdvanced
32 Text::Query::ParseSimple
33
34 The following builders are provided:
35
36 Text::Query::BuildAdvancedString
37 Text::Query::BuildSimpleString
38
39 The following solver is provided:
40
41 Text::Query::SolveSimpleString
42 Text::Query::SolveAdvancedString
43
44EXAMPLES
45 use Text::Query;
46 my $q=new Text::Query('hello and world',
47 -parse => 'Text::Query::ParseAdvanced',
48 -solve => 'Text::Query::SolveAdvancedString',
49 -build => 'Text::Query::BuildAdvancedString');
50 die "bad query expression" if not defined $q;
51 print if $q->match;
52 ...
53 $q->prepare('goodbye or adios or ta ta',
54 -litspace => 1,
55 -case => 1);
56 #requires single space between the two ta's
57 if($q->match($line)) {
58 #doesn't match "Goodbye"
59 ...
60 $q->prepare('"and" or "or"');
61 #quoting operators for literal match
62 ...
63 $q->prepare('\\bintegrate\\b', -regexp => 1);
64 #won't match "disintegrated"
65
66CONSTRUCTOR
67 new ([QSTRING] [OPTIONS])
68 This is the constructor for a new Text::Query object. If a "QSTRING"
69 is given it will be compiled to internal form.
70
71 "OPTIONS" are passed in a hash like fashion, using key and value
72 pairs. Possible options are:
73
74 -parse - Package name of the parser. Default is
75 Text::Query::ParseSimple.
76
77 -build - Package name of the builder. Default is Text::Query::Build.
78
79 -optimize - Package name of the optimizer. Default is
80 Text::Query::Optimize.
81
82 -solve - Package name of the solver. Default is Text::Query::Solve.
83
84 -mode - Name of predefined group of packages to use. Options are
85 currently "simple_text" and "advanced_text".
86
87 These options are handled by the "configure" method.
88
89 All other options are passed to the parser "prepare" function. See
90 the corresponding manual pages for a description.
91
92 If "QSTRING" is undefined, the prepare function is not called.
93
94 The constructor will croak if a "QSTRING" was supplied and had
95 illegal syntax.
96
97METHODS
98 configure ([OPTIONS])
99 Set the "parse", "build", "optimize" or "solve" packages. See the
100 "CONSTRUCTOR" description for explanations.
101
102 prepare (QSTRING [OPTIONS])
103 Compiles the query expression in "QSTRING" to internal form and sets
104 any options (same as in the constructor). "prepare" may be used to
105 change the query expression and options for an existing query
106 object. If "OPTIONS" are omitted, any options set by a previous call
107 to "prepare" are persistent.
108
109 The optimizer (-optimize) is called with the result of the parser
110 (-parse). The parser uses the builder (-build) to construct the
111 internal form.
112
113 This method returns a reference to the query object if the syntax of
114 the expression was legal, or croak if not.
115
116 match ([TARGET])
117 Calls the match method of the solver (-solve).
118
119 matchscalar ([TARGET])
120 Calls the matchscalar method of the solver (-solve).
121
122SEE ALSO
123 Text::Query::ParseAdvanced(3), Text::Query::ParseSimple(3),
124 Text::Query::BuildSimpleString(3), Text::Query::BuildAdvanedString(3),
125 Text::Query::SolveSimpleString(3), Text::Query::SolveAdvancedString(3),
126
127 Text::Query::Build(3), Text::Query::Parse(3), Text::Query::Solve(3),
128 Text::Query::Optimize(3)
129
130MAINTENANCE
131 https://github.com/jonjensen/Text-Query
132 https://rt.cpan.org//Dist/Display.html?Queue=Text-Query
133
134AUTHORS
135 Eric Bohlman (ebohlman@netcom.com)
136
137 Loic Dachary (loic@senga.org)
138
139 Jon Jensen, jon@endpoint.com
140
141