def test_max_targets_none(self): """Check that if max_targets is None it will not reduce the targets to the two closest ents. """ doc = self.create_num_target_examples() assert len(doc.ents) == 3 rule = ConTextRule("vs", category="UNCERTAIN", direction="BIDIRECTIONAL", max_targets=None) # Set "vs" to be the modifier modifier = ConTextModifier(rule, 5, 6, doc) for target in doc.ents: modifier.modify(target) assert modifier.num_targets == 3 modifier.reduce_targets() assert modifier.num_targets == 3
def test_max_targets_less_than_targets(self): """Check that if max_targets is not None it will reduce the targets to the two closest ents. """ doc = self.create_num_target_examples() assert len(doc.ents) == 3 rule = ConTextRule("vs", category="UNCERTAIN", direction="BIDIRECTIONAL", max_targets=2) # Set "vs" to be the modifier modifier = ConTextModifier(rule, 5, 6, doc) for target in doc.ents: modifier.modify(target) assert modifier.num_targets == 3 modifier.reduce_targets() assert modifier.num_targets == 2 for target in modifier._targets: assert target.lower_ in ("pneumonia", "copd")