How to match on pattern when POS doesn't apprear #10501
Unanswered
antonpibm
asked this question in
Help: Coding & Implementations
Replies: 1 comment
-
I think the import spacy
from spacy.matcher import Matcher
from spacy.displacy import render
nlp = spacy.load("en_core_web_md")
doc = nlp("I am in Brazil, which is the most beautiful country")
render(doc) Could you share a code snippet with an Also, could you perhaps share a bit more about the actual use-case you're trying to solve? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone.
I'm having trouble writing a Matcher rule for validating that a certain POS doesn't appear before some other pattern.
Example: validate that no
PROPN
exist in a sentence before the firstVERB
Currently, to solve this I have to instantiate 2 Matchers:
VERB
exist, with pattern -[{"POS": "VERB"}]
PROPN
exist somewhere before theVERB
, with pattern -[{"POS": "PROPN"},{"OP": "*"},{"POS": "VERB"}]
Then in a filtering I need to check
if matcher1 and not matcher2
Trying to negate the
PROPN
with pattern[{"IS_SENT_START": True, "POS": {"NOT_IN": ["PROPN"]},"OP": "*"}, {"POS": "VERB"}]
doesn't work, you can test againt:"I am in Brazil, which is the most beautiful country"
I guess I can check the matches programmatically, but I wonder if this could be handles via the pattern itself
Beta Was this translation helpful? Give feedback.
All reactions