spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

index out of range while training spacy

Open jacob7182 opened this issue 8 years ago • 2 comments

Hi, I am getting an error at the GoldParse nlp = spacy.load('en_core_web_sm') train_data = [('2 ABC DEF XYZ',['U-ORDINAL','O','O','O']), ('DEF Two ABC XYZ',['O','U-ORDINAL','O','O'])]

optimizer = nlp.begin_training() for itn in range(50): random.shuffle(train_data) for raw_text, entity_offsets in train_data:
doc = nlp.make_doc(raw_text)
nlp.tagger(doc) gold = GoldParse(doc, entities=entity_offsets)
nlp.entity.update([doc], [gold], drop=0.5, sgd=optimizer)

Getting an error at the line GoldParse "list index out of range"

My actual training_data has around 180 items. Is there an issue with the structure of train_data? If the issue is with the text and corresponding entity annotation, then is there a better way to catch it before the GoldParse statement to see which of the item is causing issue?

  • Operating System: Windows 64 bit
  • Python Version Used: 3.6
  • spaCy Version Used: 2.0.11
  • Environment Information:

jacob7182 avatar Jun 13 '18 13:06 jacob7182

I think i got the issue, some of the text inside train_data is having space, as a result the number of tokens and annotations are not matching.

jacob7182 avatar Jun 13 '18 14:06 jacob7182

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.

lock[bot] avatar Jul 13 '18 14:07 lock[bot]