(attributes)
return head, in_mention_span, head_index
Compute the head of the mention.

    Args:
        attributes (dict(str, object)): Attributes of the mention, must contain
            values for "tokens", "parse_tree", "pos", "ner", "is_apposition"

    Returns:
        (list(str), Span, int): The head, the head span (in the document) and
        the starting index of the head (in the mention).
Compute the head of the mention.
Compute the head of the mention .
def compute_head_information(attributes):
    """ Compute the head of the mention.

    Args:
        attributes (dict(str, object)): Attributes of the mention, must contain
            values for "tokens", "parse_tree", "pos", "ner", "is_apposition"

    Returns:
        (list(str), Span, int): The head, the head span (in the document) and
        the starting index of the head (in the mention).
    """
    mention_subtree = attributes["parse_tree"]

    head_finder = head_finders.HeadFinder()
    head_index = 0
    head = [attributes["tokens"][0]]

    if len(mention_subtree.leaves()) == len(attributes["tokens"]):
        head_tree = head_finder.get_head(mention_subtree)
        head_index = get_head_index(head_tree, mention_subtree.pos())
        head = [head_tree[0]]

    in_mention_span = spans.Span(head_index, head_index)

    if attributes["pos"][head_index].startswith("NNP"):
        in_mention_span, head = \
            head_finders.HeadFinder.adjust_head_for_nam(
                attributes["tokens"],
                attributes["pos"],
                attributes["ner"][head_index],
                in_mention_span,
                head)

    # proper name mention: head index last word of head
    # (e.g. "Obama" in "Barack Obama")
    head_index = in_mention_span.end

    # special handling for appositions
    if attributes["is_apposition"]:
        # "Secretary of State Madeleine Albright"
        # => take "Madeleine Albright" as head
        if len(mention_subtree) == 2:
            head_tree = mention_subtree[1]
            head = head_tree.leaves()
            in_mention_span = spans.Span(
                len(mention_subtree[0].leaves()),
                len(attributes["tokens"]) - 1)
            head_index = in_mention_span.end
        else:
            start = 0
            for child in mention_subtree:
                if __head_pos_starts_with(child, "NNP"):
                    end = min(
                        [start + len(child.leaves()),
                         len(attributes["tokens"])])
                    head_index = end - 1
                    in_mention_span, head = \
                        head_finders.HeadFinder.adjust_head_for_nam(
                            attributes["tokens"][start:end],
                            attributes["pos"][start:end],
                            attributes["ner"][head_index],
                            in_mention_span,
                            head)
                    break
                start += len(child.leaves())

    return head, in_mention_span, head_index
def compute_head_information ( attributes ) : mention_subtree = attributes [ "parse_tree" ] head_finder = head_finders . HeadFinder ( ) head_index = 0 head = [ attributes [ "tokens" ] [ 0 ] ] if len ( mention_subtree . leaves ( ) ) == len ( attributes [ "tokens" ] ) : head_tree = head_finder . get_head ( mention_subtree ) head_index = get_head_index ( head_tree , mention_subtree . pos ( ) ) head = [ head_tree [ 0 ] ] in_mention_span = spans . Span ( head_index , head_index ) if attributes [ "pos" ] [ head_index ] . startswith ( "NNP" ) : in_mention_span , head = head_finders . HeadFinder . adjust_head_for_nam ( attributes [ "tokens" ] , attributes [ "pos" ] , attributes [ "ner" ] [ head_index ] , in_mention_span , head ) # proper name mention: head index last word of head # (e.g. "Obama" in "Barack Obama") head_index = in_mention_span . end # special handling for appositions if attributes [ "is_apposition" ] : # "Secretary of State Madeleine Albright" # => take "Madeleine Albright" as head if len ( mention_subtree ) == 2 : head_tree = mention_subtree [ 1 ] head = head_tree . leaves ( ) in_mention_span = spans . Span ( len ( mention_subtree [ 0 ] . leaves ( ) ) , len ( attributes [ "tokens" ] ) - 1 ) head_index = in_mention_span . end else : start = 0 for child in mention_subtree : if __head_pos_starts_with ( child , "NNP" ) : end = min ( [ start + len ( child . leaves ( ) ) , len ( attributes [ "tokens" ] ) ] ) head_index = end - 1 in_mention_span , head = head_finders . HeadFinder . adjust_head_for_nam ( attributes [ "tokens" ] [ start : end ] , attributes [ "pos" ] [ start : end ] , attributes [ "ner" ] [ head_index ] , in_mention_span , head ) break start += len ( child . leaves ( ) ) return head , in_mention_span , head_index