How to programmatically get a list of all dependency parse tags of a loaded model? #5135
-
The info is statically described in the documentation, i.e., https://spacy.io/api/annotation#dependency-parsing, but what if one needs to get the list of all dependency parse tags programmatically, e.g., in case different models are employed in a system? Is there an internal structure (that probably comes with / is set when loading a model) that can be used? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
For the core components, you can access
Likewise |
Beta Was this translation helpful? Give feedback.
-
Strange, when I run this code I get an error:
will result in
|
Beta Was this translation helpful? Give feedback.
-
Hmm, I can't reproduce this. Could you provide more information about your environment ( |
Beta Was this translation helpful? Give feedback.
-
Sure, please see below: Info about spaCy
|
Beta Was this translation helpful? Give feedback.
-
That looks like a bug (#4275) that didn't get fixed until v2.2.0. Unless you have a particular reason for using v2.1, I'd recommending upgrading to a more recent version (v2.2+). If you specifically need v2.1 (and even then I'd recommend upgrading to at least v2.1.8), you have to work around that bug, but the information is still available: labels = set()
for move in nlp.parser.move_names:
if "-" in move:
move = move.split("-")[1]
if "||" in move:
move = move.split("||")[1]
labels.add(move)
assert labels == {'agent', 'acl', 'intj', 'predet', 'expl', 'prt', 'meta', 'attr', 'pcomp', 'parataxis', 'compound', 'auxpass', 'mark', 'prep', 'dative', 'xcomp', 'npadvmod', 'advcl', 'preconj', 'pobj', 'csubj', 'dep', 'punct', 'case', 'ROOT', 'quantmod', 'cc', 'det', 'subtok', 'neg', 'nmod', 'amod', 'advmod', 'nsubjpass', 'appos', 'conj', 'dobj', 'acomp', 'nsubj', 'csubjpass', 'nummod', 'ccomp', 'oprd', 'poss', 'relcl', 'aux'} |
Beta Was this translation helpful? Give feedback.
-
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Beta Was this translation helpful? Give feedback.
For the core components, you can access
.labels
: