# How do I load the output of ner.gold-to-spacy into spacy?

**URL:** <https://support.prodi.gy/t/how-do-i-load-the-output-of-ner-gold-to-spacy-into-spacy/866>\
**Category:** Uncategorized\
**Tags:** ner, spacy, solved\
**Created:** [October 8, 2018, 7:27pm UTC](https://support.prodi.gy/t/how-do-i-load-the-output-of-ner-gold-to-spacy-into-spacy/866 "2018-10-08T19:27:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![theoldhat](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@theoldhat](https://support.prodi.gy/u/theoldhat)\
**Post date:** [October 8, 2018, 7:27pm UTC](https://support.prodi.gy/t/how-do-i-load-the-output-of-ner-gold-to-spacy-into-spacy/866/1 "2018-10-08T19:27:10Z")

</div>

Hi,

I looked at this [link](https://spacy.io/usage/training#section-basics) in the spacy documentation around updating the named entity recogntion using custom training data, but the format of the training data referenced in the spacy documentation

```
TRAIN_DATA = [
    ('Who is Shaka Khan?', {
        'entities': [(7, 17, 'PERSON')]
    }),
    ('I like London and Berlin.', {
        'entities': [(7, 13, 'LOC'), (18, 24, 'LOC')]
    })
]

```

is different than the jsonl format exported from ner.gold-to-spacy. Is there an easy way to load jsonl data for use with spacy?

Thanks!

Hat

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [October 9, 2018, 8:18am UTC](https://support.prodi.gy/t/how-do-i-load-the-output-of-ner-gold-to-spacy-into-spacy/866/2 "2018-10-09T08:18:46Z")

</div>

Hi! The `ner.gold-to-spacy` format should give you data that looks like this:

```python
 ["I like London", {"entities": [[7, 13, "LOC"]]}]

```

That’s pretty much the same format as the examples above (only with a list instead of tuples, since JSON doesn’t know tuples – but that shouldn’t matter). So you should be able to just read in the JSONL file and pass the result in as the training data.

---

<div class="post-metadata">

**Author:** ![theoldhat](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@theoldhat](https://support.prodi.gy/u/theoldhat)\
**Post date:** [October 9, 2018, 5:47pm UTC](https://support.prodi.gy/t/how-do-i-load-the-output-of-ner-gold-to-spacy-into-spacy/866/3 "2018-10-09T17:47:28Z")

</div>

Hi Ines,

Thanks very much for the reply! Should I be able to use the JSONL loader that comes with Prodigy to read the file? When I try to do so I get an error saying invalid JSON?

Apologies if these are novice questions.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [October 9, 2018, 5:53pm UTC](https://support.prodi.gy/t/how-do-i-load-the-output-of-ner-gold-to-spacy-into-spacy/866/4 "2018-10-09T17:53:27Z")

</div>

No worries!

Ultimately, all you need to do is open the file, iterate over the lines and call `json.loads(line)` (or, even better, `line.strip()` to trim whitespace). You can also use the [`jsonlines` Python library](https://jsonlines.readthedocs.io/en/latest/) if that’s easier.

Alternatively, you could also just copy-paste the data into a Python list – for example:

```python
TRAIN_DATA = [
    ["I like London", {"entities": [[7, 13, "LOC"]]}]
]

```

---

<div class="post-metadata">

**Author:** ![theoldhat](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@theoldhat](https://support.prodi.gy/u/theoldhat)\
**Post date:** [October 10, 2018, 3:29pm UTC](https://support.prodi.gy/t/how-do-i-load-the-output-of-ner-gold-to-spacy-into-spacy/866/5 "2018-10-10T15:29:31Z")

</div>

Horaay Ines! I was totally backwards on this and you helped me out. I really appreciate it! Got things working now.
