问题
I have this code :
from spacy.matcher import Matcher,PhraseMatcher
import spacy
from spacy.matcher import Matcher
nlp = spacy.load("en_core_web_sm")
matcher = Matcher(nlp.vocab,validate=True)
patterns = [
[{'POS': 'QUALIF'}, {'POS': 'CCONJ'}, {'POS': 'ADJ'}, {'POS': 'NOUN'}],
]
matcher.add("process_1", None, *patterns)
texts= ["it is a beautiful and big apple"]
for text in texts:
doc = nlp(text)
matches = matcher(doc)
for _, start, end in matches:
print(doc[start:end].text)
So, I want to modify for example the POS of "beautiful"
from "ADJ"
to "QUALIF"
just before applying patterns matchers (as you know beautiful in spacy language model is "ADJ"
but me I want to modify it to "QUALIF"
just before applying the matcher.
Help please.
来源:https://stackoverflow.com/questions/65406160/how-can-i-modify-language-model-before-applying-patterns