Skip to content

Commit 029417f

Browse files
committed
Add a small bit of doc on the variable groups in Semgrex
1 parent 3c2c6a2 commit 029417f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/edu/stanford/nlp/semgraph/semgrex/SemgrexPattern.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@
229229
* This is only legal on relations with only one link between the two endpoints.
230230
* Other relations (such as grandparent) will throw a parse exception.
231231
*
232+
* <h3>Variable Groups</h3>
233+
*
234+
* If you write a node description using a regular expression, you can
235+
* assign its matching groups to variable names. If more than one node
236+
* has a group assigned to the same variable name, then matching will
237+
* only occur when all such groups capture the same string. This is
238+
* useful for enforcing coindexation constraints. The syntax is
239+
*
240+
* {@code / <regex-stuff> /#<group-number>%<variable-name> }
241+
*
242+
* For example, a pattern which looks for the same word occurring twice in a row is
243+
*
244+
* {@code {word:__#1%w} . {word:__#1%w}}
245+
*
232246
* <h3>TODO</h3>
233247
* At present a Semgrex pattern will match only once at a root node, even if there is more than one way of satisfying
234248
* it under the root node. Probably its semantics should be changed, or at least the option should be given, to return

0 commit comments

Comments
 (0)