# Export Annotated Data from ner.manual to get list of words per label

**URL:** <https://support.prodi.gy/t/export-annotated-data-from-ner-manual-to-get-list-of-words-per-label/3837>\
**Category:** Uncategorized\
**Tags:** usage, ner, database\
**Created:** [January 31, 2021, 8:49am UTC](https://support.prodi.gy/t/export-annotated-data-from-ner-manual-to-get-list-of-words-per-label/3837 "2021-01-31T08:49:52Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![ryanwesslen](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ryanwesslen/32/2969_2.png) [@ryanwesslen](https://support.prodi.gy/u/ryanwesslen)\
**Post date:** [September 7, 2022, 3:48pm UTC](https://support.prodi.gy/t/export-annotated-data-from-ner-manual-to-get-list-of-words-per-label/3837/8 "2022-09-07T15:48:56Z")

</div>

hi @do12siwu!

> [@do12siwu](#):
>
> I'm sorry for asking this in such a long-winded and complicated way.  
> I am still a beginner as far as programming is concerned.

No problem at all! We're all learning and you're doing great 🙂

> [@do12siwu](#):
>
> This is a dataset that has already been labeled by me.  
> What I was trying to do was extracting all the parts of the text that were labeled as REGEX and saving it in a list.

Oh - so is your `LABEL` is named `REGEX`?

If so, you can then use this code:

```python
from prodigy.components.db import connect
from collections import defaultdict

db = connect()
examples = db.get_dataset("koText")

label_stats = defaultdict(list)
for eg in examples:
    if eg["answer"] == "accept": # you probably want to exclude ignored/rejected answers?
        for span in eg.get("spans", []):
            word = eg["text"][span["start"]:span["end"]] # slice of the text
            label = span["label"]
            if label == "REGEX": # only keep those spans with "REGEX" labels
                label_stats[label].append(word)

print(label_stats["REGEX"])

```

This will put into a list all of your annotated spans with the label `"REGEX"`. Does this solve your problem?

---

_[View the full topic](https://support.prodi.gy/t/export-annotated-data-from-ner-manual-to-get-list-of-words-per-label/3837)._
