예제 #1
0
    def context_graph(self):
        doc = nlp("There is no evidence of pneumonia but there is chf.")
        item_data1 = ConTextItem("no evidence of",
                                 "DEFINITE_NEGATED_EXISTENCE", "forward")
        tag_object1 = TagObject(item_data1, 2, 5, doc)

        item_data2 = ConTextItem("evidence of", "DEFINITE_EXISTENCE",
                                 "forward")
        tag_object2 = TagObject(item_data2, 3, 5, doc)

        item_data3 = ConTextItem("but", "TERMINATE", "TERMINATE")
        tag_object3 = TagObject(item_data3, 6, 7, doc)

        graph = ConTextGraph()
        graph.modifiers = [tag_object1, tag_object2, tag_object3]
        return doc, graph
예제 #2
0
    def test_not_remove_modifiers_overlap_target(self):
        """Test that a modifier which overlaps with a target is not pruned but does not modify itself."""
        doc = nlp("The patient has heart failure.")
        doc.ents = (Span(doc, 3, 5, "CONDITION"), )
        context_item = ConTextItem("failure", "MODIFIER")
        tag_object = TagObject(context_item, 4, 5, doc)
        graph = ConTextGraph(remove_overlapping_modifiers=False)

        graph.modifiers = [tag_object]
        graph.targets = doc.ents
        graph.prune_modifiers()
        graph.apply_modifiers()

        assert overlap_target_modifiers(tag_object.span, doc.ents[0])
        assert len(graph.modifiers) == 1
예제 #3
0
 def test_init(self):
     assert ConTextGraph()