question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should GoldParse.__init__ accept doc=None?

See original GitHub issue

Not sure if this is bug exactly (the GoldParse API documentation isn’t specific on whether the doc argument is optional or not, but given that there is a words argument, it would be nice to not have to pass in doc when this argument has been specified

How to reproduce the behaviour

from spacy.gold import GoldParse

annotation = GoldParse(words=["some", "words"], cats={"mylabel": 1.0})

produces the following error.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-28-f161c45966e4> in <module>
----> 1 annotation = GoldParse(words=["some", "words"], cats={"mylabel": 1.0})

gold.pyx in spacy.gold.GoldParse.__init__()

TypeError: __init__() takes at least 1 positional argument (0 given)

My current workaround is something like the following, but would be nice to avoid this unless it is still necessary for a reason that I am missing.

from spacy.gold import GoldParse
import spacy

tokenizer = spacy.load('en_core_web_sm').tokenizer
annotation = GoldParse(tokenizer(" ".join(["some", "words"])), cats={"mylabel": 1.0})

Your Environment

  • spaCy version: 2.3.5
  • Platform: Darwin-20.2.0-x86_64-i386-64bit
  • Python version: 3.7.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
themrmaxcommented, Jan 25, 2021

Thanks for the clarification @svlandeg, this makes sense now!

0reactions
github-actions[bot]commented, Oct 27, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's New in v3.0 · spaCy Usage Documentation
You can use the quickstart widget or the init config command to get started. ... all take batches of Example objects instead of...
Read more >
spacy.util.minibatch Example - Program Talk
Here are the examples of the python api spacy.util.minibatch taken from open source projects. By voting up you can indicate which examples are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found