TypeError: add_label() takes exactly 2 positional arguments (3 given) #9393
-
Hello, This is the codeimport os TAG_MAP = { @plac.annotations(
if name == 'main': Expected output:[('I', 'N', 'NOUN'),('like', 'V', 'VERB'),('blue', 'J', 'ADJ'),('eggs', 'N', 'NOUN')]It fails with the following output and traceback. :dict_items([('N', {'pos': 'NOUN'}), ('V', {'pos': 'VERB'}), ('J', {'pos': 'ADJ'})]) Traceback (most recent call last): File "/home/essin/anaconda3/envs/nlp/lib/python3.9/site-packages/plac_core.py", line 348, in call File "/home/essin/anaconda3/envs/nlp/lib/python3.9/site-packages/plac_core.py", line 217, in consume File "/home/essin/nlp/train/main.py", line 36, in main File "spacy/pipeline/tagger.pyx", line 276, in spacy.pipeline.tagger.Tagger.add_label
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @Dan-Essin ! Will definitely appreciate it if you format the code block properly so that it's easier to debug. 🙇 It seems like you're following a book that uses the v2 API but the spaCy version you have in your computer is already v3. The function parameters have changed during that version bump. To confirm which spaCy version you have, try running the following: python -m spacy info You have two options here:
Lastly, the reason why it says 3 arguments instead of 2 is because Python counts def add_label(self, label):
# some code So it just expects 2. However, we are passing three arguments in the code: |
Beta Was this translation helpful? Give feedback.
Hi @Dan-Essin ! Will definitely appreciate it if you format the code block properly so that it's easier to debug. 🙇
It seems like you're following a book that uses the v2 API but the spaCy version you have in your computer is already v3. The function parameters have changed during that version bump. To confirm which spaCy version you have, try running the following:
You have two options here:
add_label
doesn't accept avalues
param anymore. You can check the migration doc here, and follow t…