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

No module named spacy.gold #35

Open
YanaSSS opened this issue Oct 26, 2022 · 14 comments · May be fixed by #38
Open

No module named spacy.gold #35

YanaSSS opened this issue Oct 26, 2022 · 14 comments · May be fixed by #38

Comments

@YanaSSS
Copy link

YanaSSS commented Oct 26, 2022

Environment

  • Operating System: Windows
  • Python Version Used: 3.9.13
  • Spacy Version Used: 3.4
  • doccano-transformer Version: module 'doccano_transformer' has no attribute 'version'

When importing from doccano_transformer.datasets import NERDataset I receive an error

ModuleNotFoundError Traceback (most recent call last)
Cell In [8], line 1
----> 1 from doccano_transformer.datasets import NERDataset
2 from doccano_transformer.utils import read_jsonl

File c:\Users\yana.stamenova\work-data\RnD_Models\venv_new\lib\site-packages\doccano_transformer\datasets.py:5
2 import json
3 from typing import Any, Callable, Iterable, Iterator, List, Optional, TextIO
----> 5 from doccano_transformer.examples import Example, NERExample
8 class Dataset:
9 def init(
10 self,
11 filepath: str,
12 encoding: Optional[str] = 'utf-8',
13 transformation_func: Optional[Callable[[TextIO], Iterable[Any]]] = None
14 ) -> None:

File c:\Users\yana.stamenova\work-data\RnD_Models\venv_new\lib\site-packages\doccano_transformer\examples.py:4
1 from collections import defaultdict
2 from typing import Callable, Iterator, List, Optional
----> 4 from spacy.gold import biluo_tags_from_offsets
6 from doccano_transformer import utils
9 class Example:

ModuleNotFoundError: No module named 'spacy.gold'

gold is part of 2.x versions of spacy. After 3.0 it is renamed to training

I have proposed an edit to examples.py

@evangeliazve
Copy link

Hello,

I have exactly the same problem as you.

@a-nematihayati
Copy link

just uncomment spacy.gold under lib/python3.8/site-packages/doccano_transformer/examples.py and you should be good.

@mbledkowski
Copy link

I have got the same issue.

@yasmineTYM
Copy link

I Just replace from spacy.gold import biluo_tags_from_offsets with from spacy.training import offsets_to_biluo_tags in the doccano_transformer/examples.py

@sagarika12123
Copy link

I Just replace from spacy.gold import biluo_tags_from_offsets with from spacy.training import offsets_to_biluo_tags in the doccano_transformer/examples.py

can you please tell me how to do this?

@yasmineTYM
Copy link

you can check the log file to see the specific path of the local file that caused the error. Once you have identified the file, you can edit the import sentence in that file to correct the issue.

@sagarika12123
Copy link

you can check the log file to see the specific path of the local file that caused the error. Once you have identified the file, you can edit the import sentence in that file to correct the issue.

got it.. but if there's a code to this- it would be helpful (I am new to changing modules on the terminal- and i do not want to mess up any paths)

@yasmineTYM
Copy link

Can you provide a screenshot of your error? I am not able to reproduce the error again..

@sagarika12123
Copy link

Screen Shot 2023-02-20 at 5 18 40 PM

@yasmineTYM
Copy link

I used
vim ~/opt/anaconda3/lib/python3.9/site-packages/doccano_transformer/examples.py

henrique-voni added a commit to henrique-voni/doccano-transformer that referenced this issue Apr 18, 2023
This suggestion updates the `spacy` methods in order to use latest package version available. According to [this documentation](https://spacy.io/usage/v3), `spacy.gold` was replaced by `spacy.training` with different method signatures.

This issue was already mentioned [here](doccano#35)
@henrique-voni henrique-voni linked a pull request Apr 18, 2023 that will close this issue
10 tasks
@henrique-voni
Copy link

Hello, i added a suggestion PR that updates the code while fixing the mentioned error in this issue. Could you please evaluate?

@AkimfromParis
Copy link

Thank you Henrique for your solution on the PR.

It produces two generator objects.
<generator object NERDataset.to_conll2003 at 0x000001D0AA7C8A50>
<generator object NERDataset.to_spacy at 0x000001D0AA7CA7A0>

But no JSON file... Is it normal?!

@henrique-voni
Copy link

Hello @AkimParis , the readme isn't much clear about the execution, but i guess it's the expected behavior. You can loop through the generator to get all samples:

for sample in NERDataset.to_conll2003():
   #...

#or   
samples = [*NERDataset.to_conll2003()]

@AkimfromParis
Copy link

Thx, I was expecting direct output files. I tried to help with your PR. The Doccano team seems very busy.
In my opinion, CoNLL2003 should be the default output file. I believe that LabelStudio is giving this option. Anyway, I will try to help the Doccano team with the documentation. : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants