import spacy

from typing import List, Optional, Generator

from .base import Detector
from ..filth import NERFilth, Filth
from ..utils import CanonicalStringSet


class SpacyDetector(Detector):
    """Use spacy's named entity recognition to clean named entities.
     List specific entities to include passing ``named_entities``
    """
    filth_cls = NERFilth
    name = 'spacy_ner'

    disallowed_nouns = CanonicalStringSet(["skype"])

    def __init__(self, named_entities: Optional[List[str]] = None, model: str = "en_core_web_trf", **kwargs):
        self.named_entities = named_entities
        if model not in spacy.info()['pipelines']:
            raise OSError(f"Can't find model '{model}'. If it is a valid Spacy model, "
                          f"download it (e.g. with the CLI command "
                          f"`python -m spacy download {model}`).")
        self.nlp = spacy.load(model)
        # Only enable necessary pipes
        self.nlp.select_pipes(enable=["transformer", "tagger", "parser", "ner"])
        super(SpacyDetector, self).__init__(**kwargs)

    def iter_filth(self, text: str, document_name: Optional[str] = None) -> Generator[Filth, None, None]:
        pass

@@ -30,33 +30,61 @@
 ort 
-List, Optional, Generator
+Dict, Generator, List, Optional, Set, Sequence, Union
 %0A%0Afr
@@ -350,16 +350,36 @@
 tities%60%60
+, e.g.%0A     (PERSON)
 %0A    %22%22%22
@@ -530,16 +530,22 @@
 ptional%5B
+Union%5B
 List%5Bstr
@@ -549,17 +549,51 @@
 str%5D
-%5D = None,
+, Set%5Bstr%5D%5D%5D = %7B'PERSON'%7D,%0A                
  mod
@@ -644,29 +644,99 @@
     
-self.named_entities =
+# Spacy NER are all upper cased%0A        self.named_entities = %7Bentity.upper() for entity in
  nam
@@ -746,16 +746,17 @@
 entities
+%7D
 %0A       
@@ -1234,16 +1234,576 @@
 wargs)%0A%0A
+    def iter_filth_documents(self, documents: Union%5BSequence%5Bstr%5D, Dict%5Bstr, str%5D%5D) -%3E Generator%5BFilth, None, None%5D:%0A        if isinstance(documents, list):%0A            for doc in self.nlp.pipe(documents):%0A                for ent in doc.ents:%0A                    if ent.label_ in self.named_entities:%0A                        yield self.filth_cls(beg=ent.start_char,%0A                                             end=ent.end_char,%0A                                             text=ent.text,%0A                                             detector_name=self.name)%0A%0A
     def 
@@ -1892,29 +1892,29 @@
 h, None, None%5D:%0A
-
         pass%0A
@@ -1913,8 +1913,11 @@
    pass%0A
+%0A%0A%0A

Add iter_filth_documents basic logic