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

Custom Entities Overlapping with Pre defined Entities #16

Closed
Parth09P opened this issue Jul 20, 2020 · 1 comment
Closed

Custom Entities Overlapping with Pre defined Entities #16

Parth09P opened this issue Jul 20, 2020 · 1 comment

Comments

@Parth09P
Copy link

I'm trying to train a NER model using the given .xlsx sheet. This was working well before when the Spacy version was lower than 2.1.0. However, after upgrading to Spacy 2.3.3, I'm getting the following error:

ValueError: [E103] Trying to set conflicting doc.ents: '(0, 2, 'ORG')' and '(0, 2, 'Runbook')'. A token can only be part of one entity, so make sure the entities you're setting don't overlap.

The entire Traceback is as follows:


ValueError Traceback (most recent call last)
in
----> 1 excelcy = ExcelCy.execute(file_path='C:/Train17.xlsx')

~\Anaconda3\envs\Env1\lib\site-packages\excelcy\excelcy.py in execute(cls, file_path)
38 if phase.enabled:
39 fno = getattr(excelcy, phase.fn)
---> 40 fno(**phase.args)
41
42 return excelcy

~\Anaconda3\envs\Env1\lib\site-packages\excelcy\excelcy.py in prepare(self)
190 # identify sentences
191 for _, train in self.storage.train.items.items():
--> 192 self._prepare_parse(train=train)
193 return self
194

~\Anaconda3\envs\Env1\lib\site-packages\excelcy\excelcy.py in _prepare_parse(self, train)
169 def prepare_parse(self, train: Train):
170 # parsing pre-identified Entity based on current data model
--> 171 doc = self.nlp(train.text)
172 for ent in doc.ents:
173 subtext, offset, label = ent.text, '%s,%s' % (ent.start_char, ent.end_char), ent.label

~\Anaconda3\envs\Env1\lib\site-packages\spacy\language.py in call(self, text, disable, component_cfg)
444 if not hasattr(proc, "call"):
445 raise ValueError(Errors.E003.format(component=type(proc), name=name))
--> 446 doc = proc(doc, **component_cfg.get(name, {}))
447 if doc is None:
448 raise ValueError(Errors.E005.format(name=name))

~\Anaconda3\envs\Env1\lib\site-packages\excelcy\pipe.py in call(self, doc)
75 # start add them into entities list
76 entity = (match_id, start, end)
---> 77 doc.ents += (entity,)
78
79 return doc

doc.pyx in spacy.tokens.doc.Doc.ents.set()

Any ideas how I can workaround or bypass this one? Or maybe am I erring to input correct values? Suggestions would be greatly appreciated.

@kororo
Copy link
Owner

kororo commented Aug 23, 2020

@Parth09P, thanks for the bug submission. It is apparently update changes from spaCy that overlapping span is not allowed.

explosion/spaCy#2550
explosion/spaCy#3608

I made changes to the version 0.4.1, please do install the latest version.

However, just a note, do not do training with overlapping span for example
Sentence: one two three
if you do: one is NUMBER
and: one two is NUMBER

The error still persist, because there is overlapping span of one

Thanks

@kororo kororo closed this as completed Aug 23, 2020
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

No branches or pull requests

2 participants