Esempio n. 1
0
class TestPhiWithinRange(unittest.TestCase):
    def setUp(self):
        self.has_overlap_sa = StandoffAnnotation(
            os.path.join(FIXTURES_PATH, "has_overlap1.xml"))

    def test_returns_all_phi_for_entire_document_range(self):
        all_phi_maybe = phi_within_range(self.has_overlap_sa, 0,
                                         len(self.has_overlap_sa.text))

        self.assertEqual(all_phi_maybe, self.has_overlap_sa.get_phi())
Esempio n. 2
0
class TestSaFilterByPhiAttrs(unittest.TestCase):
    def setUp(self):
        self.sa1 = StandoffAnnotation(
            os.path.join(FIXTURES_PATH, "has_overlap1.xml"))

    def test_filtering(self):
        # No PHI will have an attribute of foo
        self.assertEqual(sa_filter_by_phi_attrs(self.sa1, {"foo": "bar"}), [])

        # No filters should be the same as all the PHI
        self.assertEqual(sa_filter_by_phi_attrs(self.sa1, {}),
                         self.sa1.get_phi())

        # There should only be one PHI with the id P1.
        assert (len(sa_filter_by_phi_attrs(self.sa1, {"id": "P1"})) == 1)