pythonnlppattern-matchingspacy

How to tag words that not include one specific symbol in Spacy?


I'm trying to tag one word in Spacy using regex, but I want to add one condition: it can't contain symbol '/' in any place inside. My code looks like this:

[{'lower': {"regex": "^.*(word).*?"}}]

I tried using ^ to exclude this but It didn't work.

So examples:

  1. 'subwordw' tagged: 'subword'
  2. 'subword/w' tagged nothing

Solution

  • try this: {'lower': {'REGEX': "^([^\/]*word[^\/]*)$"}}