Alt-CWB-ambs
view release on metacpan or search on metacpan
data/vrt/VeryShortStories.vrt view on Meta::CPAN
's POS 's
work NN work
. SENT .
</s>
<s>
First JJ first
of IN of
all DT all
, , ,
an DT an
accident NN accident
had VBD have
happened VBN happen
in IN in
a DT a
nuclear JJ nuclear
power NN power
station NN station
. SENT .
</s>
<s>
data/vrt/VeryShortStories.vrt view on Meta::CPAN
, , ,
soft JJ soft
, , ,
and CC and
sexy JJ sexy
voice NN voice
. SENT .
</s>
<s>
Ed NP Ed
decided VBD decide
that IN that
it PP it
was VBD be
time NN time
for IN for
lunch NN lunch
. SENT .
</s>
<s>
He PP he
data/vrt/VeryShortStories.vrt view on Meta::CPAN
evening NN evening
. SENT .
</s>
<s>
After IN after
exchanging VBG exchange
some DT some
trivialities NNS triviality
, , ,
they PP they
decided VBD decide
to TO to
go VB go
to TO to
the DT the
movies NNS movie
and CC and
then RB then
dine VB dine
in IN in
a DT a
data/vrt/VeryShortStories.vrt view on Meta::CPAN
Some DT some
pitiful JJ pitiful
journalist NN journalist
, , ,
who WP who
was VBD be
sacked VBD sack
soon RB soon
after IN after
the DT the
incident NN incident
, , ,
had VBD have
discovered VBN discover
that IN that
The DT the
Real NP Real
Popcorn NP Popcorn
was VBD be
made VBN make
from IN from
data/vrt/VeryShortStories.vrt view on Meta::CPAN
seemed VBD seem
to TO to
be VB be
blood NN blood
dripping VBG drip
off RP off
the DT the
wrist NN wrist
of IN of
a DT a
suicide NN suicide
. SENT .
</s>
<s>
The DT the
bubbling VBG bubble
went VBD go
on RP on
, , ,
neither CC neither
growing VBG grow
data/vrt/VeryShortStories.vrt view on Meta::CPAN
</s>
<s>
On IN on
the DT the
spur NN spur
of IN of
the DT the
moment NN moment
, , ,
I PP I
decided VBD decide
to TO to
tease VB tease
Bert NP Bert
a DT a
little JJ little
. SENT .
</s>
</p>
<p>
<s>
data/vrt/VeryShortStories.vrt view on Meta::CPAN
is VBZ be
exactly RB exactly
as RB as
far RB far
as IN as
I PP I
got VBD get
when WRB when
I PP I
finally RB finally
decided VBD decide
to TO to
give VB give
the DT the
zoo NN zoo
a DT a
try VBP try
for IN for
want VBP want
of IN of
a DT a
lib/CWB/CEQL/Parser.pm view on Meta::CPAN
does not match the input string, the entire parsing process fails. Again,
this decision was motivated by the observation that, in the case of simplified
query languages, it is often very easy to make such deterministic decisions
with a regular expression and/or a few lines of Perl code.
Each B<DPP rule> is implemented as a B<Perl subroutine> (or, more precisely,
B<method>). It is invoked by the parser with an input string that is expected
to be a constituent of the respective type, and returns its analysis of this
constituent. In the typical application of DPP grammars, the return value is
a string representing (part of) a low-level query expression, but grammar
authors may also decide to return arbitrary data structures. In the B<rule
body>, other grammar rules can be applied to the full input string, a
substring, or an arbitrarily transformed substring using the B<Call> method.
It is also possible to invoke the shift-reduce-type parser with the B<Apply>
method. Both methods return an analysis of the given substring, which can
then be integrated with the analyses of other substrings and the parsing
performed by the rule body itself.
The section on L<"WRITING GRAMMARS"> below explains in detail how to write new
DPP grammars from scratch; L<"GRAMMAR RULES"> presents some typical design
patterns for grammar rules and lists the methods available to grammar writers;
lib/CWB/CEQL/Parser.pm view on Meta::CPAN
Internally, B<Parse> will invoke appropriate grammar rules. In the first
example above, the B<default> method would be called with argument I<$string>;
in the second example, B<some_rule> would be called. A typical DPP rule
performs the following operations:
=over 4
=item 1.
examine the input string to decide whether it appears to be a suitable
constituent, and to determine its internal structure
=item 2.
if the test in Step 1 fails, B<die> with a meaningful error message;
the B<Parse> method will catch this exception and report it to the user
together with a stack trace of where the error occured
=item 3.
lib/CWB/CEQL/Parser.pm view on Meta::CPAN
=head1 GRAMMAR RULES
=head2 Stand-alone rules
The simplest DPP rules are stand-alone rules that transform their input string
directly without invoking any subrules. These rules typically make use of regular
expression substitutions and correspond to one part of the substitution cascade
in a traditional implementation of simple query languages. In contrast to such
cascades, DPP rules apply only to relevant parts of the input string and cannot
accidentally modify other parts of the simple query. The example below transforms
a search term with shell-style wildcards (C<?> and C<*>) into a regular expression.
Note how the input string is first checked to make sure it does not contain any
other metacharacters that might have a special meaning in the generated regular
expression, and B<die>s with an informative error message otherwise.
sub wildcard_expression {
my ($self, $input) = @_;
die "the wildcard expression ''$input'' contains invalid characters\n"
unless $input =~ /^[A-Za-z0-9?*-]+$/;
my $regexp = $input;
( run in 1.305 second using v1.01-cache-2.11-cpan-4505f990765 )