def _assert_finds(self, tagged_text, *refs):
     """Compare the derived results to an expected number of references"""
     finder = def_finders.XMLTermMeans()
     text = re.sub(r"<[^>]*>", "", tagged_text)  # removes tags
     node = Node(text)
     node.tagged_text = tagged_text
     actual = finder.find(node)
     self.assertEqual(len(refs), len(actual))
     for ref, actual in zip(refs, actual):
         self.assertEqual(ref.term, actual.term)
         self.assertEqual(ref.start, actual.start)
예제 #2
0
    def node_definitions(self, node, stack=None):
        """Find defined terms in this node's text."""
        references = []
        stack = stack or ParentStack()
        for finder in (def_finders.ExplicitIncludes(),
                       def_finders.SmartQuotes(stack),
                       def_finders.ScopeMatch(self.scope_finder),
                       def_finders.XMLTermMeans(references),
                       def_finders.DefinitionKeyterm(stack.parent_of(node))):
            # Note that `extend` is very important as XMLTermMeans uses the
            # list reference
            references.extend(finder.find(node))

        references = [r for r in references if len(r.term) <= MAX_TERM_LENGTH]

        return ([r for r in references if not self.is_exclusion(r.term, node)],
                [r for r in references if self.is_exclusion(r.term, node)])