The numbered target markers feature, introduced with CQP v3.4.16, provides a work-around solution for marking up to 10 anchor positions in a finite-state query (with support from wrapper scripts, as discussed below).
@ sign, setting the target anchor to the matching corpus position.
If multiple target markers are specified, the one encountered last
during query evaluation “wins”.
@.
> [pos="DT"] [pos="RB"] [pos="JJ"] [pos="JJ"] [pos="N.*"];
@0 ... @9. Only two of them are active
at a given time, controlled by the user options AnchorNumberTarget
(ant) and AnchorNumberKeyword (ank).
> [pos="DT"] @0[pos="RB"] @1[pos="JJ"] @2[pos="JJ"] [pos="N.*"];
@0 and @1
are active by default. Re-run the query after changing
AnchorNumberTarget in order to mark the second adjective as target,
instead of the adverb.
> set AnchorNumberTarget 2;
> [pos="DT"] @0[pos="RB"] @1[pos="JJ"] @2[pos="JJ"] [pos="N.*"];
@0 and @1,
@2 and @3, etc.).
> set AnchorNumberTarget 0; set AnchorNumberKeyword 1;
> Result = [pos="DT"] @0[pos="RB"] @1[pos="JJ"] @2[pos="JJ"] [pos="N.*"];
> Temp = <<Result/>> ( [pos="DT"] @0[pos="RB"] @1[pos="JJ"] @2[pos="JJ"] [pos="N.*"] );
> dump Temp; # obtain matching ranges and first two target anchors @0 and @1
> set AnchorNumberTarget 2; set AnchorNumberKeyword 3;
> Temp = <<Result/>> ( [pos="DT"] @0[pos="RB"] @1[pos="JJ"] @2[pos="JJ"] [pos="N.*"] );
> dump Temp; # obtain next two target anchors @2 and @3
> set AnchorNumberTarget 8; set AnchorNumberKeyword 9;
> Temp = <<Result/>> ( [pos="DT"] @0[pos="RB"] @1[pos="JJ"] @2[pos="JJ"] [pos="N.*"] );
> dump Temp; # obtain last two target anchors @8 and @9
@ marker unconditionally sets
the target anchor, regardless of the value of AnchorNumberTarget.
Queries should never mix @ with the numbered potential target markers.
@: for the
unconditional target).
> [pos="DT"] @0:[pos="RB"] @1:[pos="JJ"] @2:[pos="JJ"] [pos="N.*"];
This simplifies CQP macros, which do not have to distinguish between label names and target markers passed as arguments.
MACRO np($0=MarkNoun $1=MarkAdj) ( [pos="DT"]? [pos="RB"]? $1[pos="JJ.*"]* $0[pos="NN.*"] ) ; MACRO np($0=MarkNoun) /np["$0", ""] ; MACRO np(0) /np["", ""] ;
"" omits
the corresponding marker. The two additional macros simulate default values
(no marker) for both arguments.
> /np["@1", "@0"] @2[pos="IN"] /np["@3"];
This query applies @0 to the adjective of the first NP,
@1 to its head noun, @2 to the preposition and @3
to the head noun of the PP.
MACRO np($0=StartNoun $1=EndNoun $2=MarkAdj) ( [pos="DT"]? [pos="RB"]? $2[pos="JJ.*"]* $0[::] $1[pos="NN.*"]+ ) ;
Due to the matching rules, the marker indicated by $1 will be set to
the last noun in the sequence (which may be identical to the first noun
marked by $0). Keep in mind that /np[] only matches a single
noun token unless it is embedded in a larger query or the matching strategy
is set to longest.