Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructing DocBin with attrs=None or a list doesn't work #5577

Closed
cuckookernel opened this issue Jun 11, 2020 · 3 comments
Closed

Constructing DocBin with attrs=None or a list doesn't work #5577

cuckookernel opened this issue Jun 11, 2020 · 3 comments
Labels
feat / doc Feature: Doc, Span and Token objects feat / serialize Feature: Serialization, saving and loading

Comments

@cuckookernel
Copy link

How to reproduce the behaviour

from spacy.tokens import DocBin

doc_bin = DocBin()

This should work according to the docs, as argument attrs to the constructor allows for None
default value or a list of strings. This, however, throws an exception:

Traceback (most recent call last):
  File "/home/teo/miniconda3/envs/bokeh2/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3331, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-98911ff55469>", line 3, in <module>
    a = DocBin()
  File "/home/teo/miniconda3/envs/bokeh2/lib/python3.7/site-packages/spacy/tokens/_serialize.py", line 56, in __init__
    attrs = sorted(intify_attrs(attrs))
  File "attrs.pyx", line 144, in spacy.attrs.intify_attrs
AttributeError: 'list' object has no attribute 'items'

The error apparently stems from the fact that even though attrs is a list (the empty list in this case),
intify_attrs seems to expect a dictionary.

Your Environment

Info about spaCy

  • spaCy version: 2.2.0

  • Platform: Linux-5.0.0-32-generic-x86_64-with-debian-buster-sid

  • Python version: 3.7.6

  • Environment Information:

@adrianeboyd adrianeboyd added feat / doc Feature: Doc, Span and Token objects feat / serialize Feature: Serialization, saving and loading labels Jun 12, 2020
@adrianeboyd
Copy link
Contributor

Hi, it looks like this was fixed in v2.2.1 (by #4368). Can you try upgrading? If there's no particular reason for preferring an earlier version, then we'd recommend the most recent release, v2.2.4.

@cuckookernel
Copy link
Author

It does indeed work on v2.2.4

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2021

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat / doc Feature: Doc, Span and Token objects feat / serialize Feature: Serialization, saving and loading
Projects
None yet
Development

No branches or pull requests

2 participants