Ejemplo n.º 1
0
 def test_limit_scope3(self):
     """Test that two modifiers of the same type limit the scope of the first modifier."""
     doc = nlp("no evidence of CHF, neg for pneumonia")
     item = ConTextItem("no evidence of", "DEFINITE_NEGATED_EXISTENCE",
                        "FORWARD")
     item2 = ConTextItem("neg for", "DEFINITE_NEGATED_EXISTENCE", "FORWARD")
     tag_object = TagObject(item, 0, 3, doc)
     tag_object2 = TagObject(item2, 5, 7, doc)
     assert tag_object.limit_scope(tag_object2)
Ejemplo n.º 2
0
    def test_terminate_limit_scope_backward(self):
        """Test that a 'TERMINATE' modifier will limit the scope of a 'BACKWARD' modifier.
        """
        doc = nlp("Pt has chf but pneumonia is ruled out")
        item = ConTextItem("is ruled out", "NEGATED_EXISTENCE", "BACKWARD")
        tag_object = TagObject(item, 6, 8, doc)

        item2 = ConTextItem("but", "TERMINATE", "TERMINATE")
        tag_object2 = TagObject(item2, 3, 4, doc)
        assert tag_object.limit_scope(tag_object2)
Ejemplo n.º 3
0
 def test_terminate_limit_scope_custom2(self):
     """Test that a modifier will be explicitly terminated by a modifier with a category
     in terminated_by."""
     doc = nlp("flu is negative, pneumonia is positive.")
     item = ConTextItem("negative", "NEGATED_EXISTENCE", rule="BACKWARD")
     item2 = ConTextItem("positive",
                         "POSITIVE_EXISTENCE",
                         rule="BACKWARD",
                         terminated_by={"NEGATED_EXISTENCE"})
     tag_object = TagObject(item, 2, 3, doc)
     tag_object2 = TagObject(item2, 6, 7, doc)
     assert tag_object2.limit_scope(tag_object)
Ejemplo n.º 4
0
 def test_terminate_limit_scope_custom(self):
     """Test that a modifier will be explicitly terminated by a modifier with a category
     in terminated_by."""
     doc = nlp("negative for flu, positive for pneumonia.")
     item = ConTextItem("negative for",
                        "NEGATED_EXISTENCE",
                        rule="FORWARD",
                        terminated_by={"POSITIVE_EXISTENCE"})
     item2 = ConTextItem("positive for",
                         "POSITIVE_EXISTENCE",
                         rule="FORWARD")
     tag_object = TagObject(item, 0, 2, doc)
     tag_object2 = TagObject(item2, 4, 6, doc)
     assert tag_object.limit_scope(tag_object2)
Ejemplo n.º 5
0
    def test_no_limit_scope_same_category_different_allowed_types(self):
        """Test that a two TagObjects of the same type but with different
         allowed types does not limits the scope of the tag object.
         """
        doc = nlp("no history of travel to Puerto Rico, neg for pneumonia")

        item = ConTextItem(
            "no history of",
            "DEFINITE_NEGATED_EXISTENCE",
            "FORWARD",
            allowed_types={"TRAVEL"},
        )
        item2 = ConTextItem(
            "neg for",
            "DEFINITE_NEGATED_EXISTENCE",
            "FORWARD",
            allowed_types={"CONDITION"},
        )
        tag_object = TagObject(item, 0, 3, doc)
        tag_object2 = TagObject(item2, 8, 10, doc)
        assert not tag_object.limit_scope(tag_object2)
Ejemplo n.º 6
0
 def test_limit_scope2(self):
     doc, item, tag_object = self.create_objects()
     item2 = ConTextItem("but", "TERMINATE", "TERMINATE")
     tag_object2 = TagObject(item2, 2, 4, doc)
     assert not tag_object2.limit_scope(tag_object)