# Path: epitator/annotator.py
# class Annotator(object):
#     def annotate(self, doc):
# 
# Path: epitator/infection_annotator.py
# class InfectionAnnotator(Annotator):
#     def annotate(self, doc, debug=False):
#         doc.require_tiers('spacy.tokens', 'spacy.nes', via=SpacyAnnotator)
#         spans = []
#         spans.extend(from_noun_chunks_with_infection_lemmas(doc, debug))
#         spans.extend(from_noun_chunks_with_person_lemmas(doc, debug))
#         tier = add_count_modifiers(spans, doc)
#         return {
#             'infections': AnnoTier(
#                 [span for span in tier if 'recovered' not in span.metadata['attributes']],
#                 presorted=True)}


import unittest
from . import test_utils
from epitator.annotator import AnnoDoc
from epitator.infection_annotator import InfectionAnnotator
from six.moves import zip

class TestInfectionAnnotator(unittest.TestCase):

    def setUp(self):
        self.annotator = InfectionAnnotator()

    def assertHasCounts(self, sent, counts):
        doc = AnnoDoc(sent)
        doc.add_tier(self.annotator)
        actuals = [span.metadata.get('count') for span in doc.tiers['infections']]
        expecteds = [count.get('count') for count in counts]
        self.assertEqual(actuals, expecteds)
        for actual, expected in zip(doc.tiers['infections'].spans, counts):
            test_utils.assertMetadataContents(actual.metadata, expected)

    def test_no_counts(self):
        doc = AnnoDoc('Fever')
        doc.add_tier(self.annotator)

    def test_false_positive_counts(self):
        examples = [
            # 'In the case of mosquito-borne diseases indoor spraying is a common intervention',
            'Measles - Democratic Republic of the Congo (Katanga) 2007.1775',
            'Meningitis - Democratic Republic of Congo [02] 970814010223',
            'On 11 / 16 / 1982 the The Last Unicorn was the most popular movie.'
        ]
        for example in examples:
            self.assertHasCounts(example, [])

    def test_age_elimination(self):

# Path: epitator/annotator.py
# class Annotator(object):
#     def annotate(self, doc):
# 
# Path: epitator/infection_annotator.py
# class InfectionAnnotator(Annotator):
#     def annotate(self, doc, debug=False):
#         doc.require_tiers('spacy.tokens', 'spacy.nes', via=SpacyAnnotator)
#         spans = []
#         spans.extend(from_noun_chunks_with_infection_lemmas(doc, debug))
#         spans.extend(from_noun_chunks_with_person_lemmas(doc, debug))
#         tier = add_count_modifiers(spans, doc)
#         return {
#             'infections': AnnoTier(
#                 [span for span in tier if 'recovered' not in span.metadata['attributes']],
#                 presorted=True)}


# Path: tests/annotator/test_infection_annotator.py
import unittest
from . import test_utils
from epitator.annotator import AnnoDoc
from epitator.infection_annotator import InfectionAnnotator
from six.moves import zip


class TestInfectionAnnotator(unittest.TestCase):

    def setUp(self):
        self.annotator = InfectionAnnotator()

    def assertHasCounts(self, sent, counts):
        doc = AnnoDoc(sent)
        doc.add_tier(self.annotator)
        actuals = [span.metadata.get('count') for span in doc.tiers['infections']]
        expecteds = [count.get('count') for count in counts]
        self.assertEqual(actuals, expecteds)
        for actual, expected in zip(doc.tiers['infections'].spans, counts):
            test_utils.assertMetadataContents(actual.metadata, expected)

    def test_no_counts(self):
        doc = AnnoDoc('Fever')
        doc.add_tier(self.annotator)

    def test_false_positive_counts(self):
        examples = [
            # 'In the case of mosquito-borne diseases indoor spraying is a common intervention',
            'Measles - Democratic Republic of the Congo (Katanga) 2007.1775',
            'Meningitis - Democratic Republic of Congo [02] 970814010223',
            'On 11 / 16 / 1982 the The Last Unicorn was the most popular movie.'
        ]
        for example in examples:
            self.assertHasCounts(example, [])

    def test_age_elimination(self):

        doc = AnnoDoc(