def get_valid_node_min_span()

in modeling/coval/conll/mention.py [0:0]


    def get_valid_node_min_span(self, root, valid_tags, min_spans):
        if not root:
            return

        terminal_shortest_depth = float('inf')
        queue = [(root, 0)]

        while queue:
            node, depth = queue.pop(0)

            if node.isTerminal and depth <= terminal_shortest_depth:
                if self.is_a_valid_terminal_node(node.tag, node.pos):
                    min_spans.add((node.tag, node.index))
                    terminal_shortest_depth = min(terminal_shortest_depth, depth)

            elif (not min_spans or depth < terminal_shortest_depth )and node.children and \
                 (depth== 0 or not valid_tags or node.tag[0:2] in valid_tags):
                for child in node.children:
                    if not child.isTerminal or (valid_tags and node.tag[0:2] in valid_tags):
                        queue.append((child, depth+1))