From 80a9652617a2cf7b76bd9bfb57f6d60ec393a8d8 Mon Sep 17 00:00:00 2001 From: Joel Nothman Date: Tue, 24 Oct 2017 15:48:22 +1100 Subject: [PATCH] DOC "OP" key in token spec --- website/docs/usage/rule-based-matching.jade | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/website/docs/usage/rule-based-matching.jade b/website/docs/usage/rule-based-matching.jade index db7c70608..cf27a6a94 100644 --- a/website/docs/usage/rule-based-matching.jade +++ b/website/docs/usage/rule-based-matching.jade @@ -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