Skip to content
Discussion options

You must be logged in to vote

How to create correctly the Example? I try with this code:

 doc = nlp.make_doc(text)
examples = [Example.from_dict(doc, { "tags": [annotation] } )]

But it get the following error:

ValueError: [E971] Found incompatible lengths in `Doc.from_array`: 1 for the array and 7 for the Doc itself.

How I should create it?

Thanks for your question!

There should be one tag per token, hence Doc length and annotation length should match. Here's an example, there are 2 tokens in my Doc:

>>> text = "you go"
>>> doc = nlp.make_doc(text)
>>> annotation = ["PRON", "VERB"]
>>> example = Example.from_dict(doc, {"tags": annotation})

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@DuyguA
Comment options

@nicolalandro
Comment options

@DuyguA
Comment options

@nicolalandro
Comment options

Answer selected by svlandeg
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usage General spaCy usage feat / training Feature: Training utils, Example, Corpus and converters
2 participants