Tregex/Tsurgeon FAQ

Questions

  1. Is there a User Guide?
  2. What command-line options does Tregex have?
  3. Tsurgeon has stopped responding/gone into an infinite loop. Is that a bug?

Questions with answers

  1. Is there a User Guide?

    At present, no. There is:

  2. What command-line options does Tregex have?

    Here are some details on the command-line options of Tregex, taken from the javadoc for the main method of TregexPattern:

    Usage:

    java edu.stanford.nlp.trees.tregex.TregexPattern [[-TCwfosnu] [-filter] [-h <node-name>]]* pattern filepath

    Arguments:

    Options:

  3. Tsurgeon has stopped responding/gone into an infinite loop. Is that a bug?

    Probably not (though you never know). Normally what this means is that you have written an infinite loop in your tree surgery script.

    Tsurgeon script matching and rewriting is applied repeatedly (recursively) until no further matching and rewriting is possible. This is the behavior that you want in complex cases: large trees may match several patterns in a complex Tsurgeon script, and earlier edits may enable later edits. However, unfortunately, it also makes it very easy to write infinite loops in Tsurgeon, and this can confuse beginners. Here's a very simple example of how you can produce an infinite loop (you can come up with complex examples by yourself!):

    /^VB/=haveaux < have|has|having|had

    relabel haveaux /^(.*)$/$1-HAVE/

    The first poor haveaux node that matches the pattern, say (VBZ has), will get repeatedly relabeled as:

    VBZ-HAVE
    VBZ-HAVE-HAVE
    VBZ-HAVE-HAVE-HAVE
    VBZ-HAVE-HAVE-HAVE-HAVE
    ...

    And you can see where that is heading. It is essential to write edits so that they will not apply to their own output forever. For this example, things can easily be fixed with the following changed script:

  4. /^VB.?$/=haveaux < have|has|having|had

    relabel haveaux /^(.*)$/$1-HAVE/

For other questions, feedback, extensions, or bugfixes, please join and post to the parser-user@lists.stanford.edu mailing list. Or you can send email to parser-support@lists.stanford.edu.