Skip to content

A limitation on AttributeRuler (Mappings & Exceptions)? #9373

Discussion options

You must be logged in to vote

I'm not entirely sure I understand what you're saying because you say "nothing happens" but you also say "the sequence is captured", but I think the issue is you can't seem to match a DET PRON sequence, right? Here's an example:

import spacy

nlp = spacy.load("en_core_web_sm")
text = "I saw The You perform. Who did you see?"
doc1 = nlp(text)
print(doc1[2].tag_, doc1[2].pos_)  # DT DET
print(doc1[3].tag_, doc1[3].pos_)  # WP PRON

# Add attribute ruler with exception for "The Who" as NNP/PROPN NNP/PROPN
ruler = nlp.get_pipe("attribute_ruler")
#print(ruler.patterns) # XXX use this to debug
# Pattern to match "The Who"
patterns = [[{"POS": "DET"}, {"POS": "PRON"}]]
# The attributes to assign…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ricardojosehlima
Comment options

Answer selected by svlandeg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usage General spaCy usage feat / matcher Feature: Token, phrase and dependency matcher
2 participants
Converted from issue

This discussion was converted from issue #9365 on October 05, 2021 05:19.