Spacy-Operator-Quantifier

05-10-2022 || 00:48
Tags: #spacy #nlp

spacy-operator-quantifier

pattern = [
   {"LEMMA": "buy"},
   {"POS": "DET", "OP": "?"}, # optional: match 0 or 1 times
   {"POS": "NOUN"}
]

The above pattern will match bought a smartphone, buying apps

There are different operator and quantifiers in spacy.

  • ! - negation, match 0 times
  • ? - Optional, mathc 0/1 times
  • + - Match 1 or more times
  • * - Match 0 or more times

References