DOC "OP" key in token spec

This commit is contained in:
Joel Nothman 2017-10-24 15:48:22 +11:00 committed by GitHub
parent 00fc2db7ef
commit 80a9652617

View File

@ -59,6 +59,10 @@ p
+h(2, "quantifiers") Using quantifiers
p
| Token specifiers may have quantifiers attached to them, by setting the "OP" key
| to one of the following values:
+table([ "Name", "Description", "Example"])
+row
+cell #[code !]
@ -80,10 +84,18 @@ p
+cell match 0 or 1 times
+cell optional, max one
p
| Thus the following matcher will match "Hello, World" or "Hello world" or "Hello - - world":
+code.
matcher = Matcher(nlp.vocab)
matcher.add_pattern("HelloWorld", [{LOWER: "hello"}, {IS_PUNCT: True, 'OP': '*'}, {LOWER: "world"}])
p
| There are no nested or scoped quantifiers. You can build those
| behaviours with acceptors and
| #[+api("matcher#add_entity") #[code on_match]] callbacks.
| All the operators are greedy: they will match as many tokens as possible.
+h(2, "acceptor-functions") Acceptor functions