I am using spacy to parsing some text. I am defining my own patterns. However, I need to consider the POS, the dependency. For example, would like to use the following pattern (with POS and DEP):
pattern = [
{'POS': {'IN': ['NOUN','ADJ'] } ,
"DEP": {'IN': ['attr', 'amod']},
"OP": "+"},
{'TEXT': {'IN': ['to','of', 'on','by','from','in']} , "OP": "+"},
{'POS': {'IN': ['NOUN','VERB']}}
]
But, the spyder return to an error:
matcher.add('rule', [pattern])
^
IndentationError: unexpected indent
I have imported both matchers, but I only used one matcher, as follows:
from spacy.matcher import Matcher
from spacy.matcher import DependencyMatcher
matcher = Matcher(nlp.vocab)
matcher.add('rule', [pattern]) #### the error shows in this line####
matches = matcher(doc)
I thought the reason might be, I use both POS and DEP, whereas, I only add the pattern in Matcher but not DependencyMatcher? Is it like this? If so, how should I correct it?
Thanks!