def from_mention(cls, mention): if not isinstance(mention, document.Mention): raise ParseEntityError( 'from_mention must be called with a {} instance'.format( get_class_name(document.Mention))) # NOBUG: just use ner of the head token, should be correct ner = mention.head_token.ner if ner not in consts.VALID_NER_TAGS: ner = '' return cls(mention.sent_idx, mention.start_token_idx, mention.end_token_idx, mention.head_token_idx, mention.rep, [Token.from_token(token) for token in mention.tokens], ner)
def from_mention(cls, mention): check_type(mention, corenlp.Mention) sent_idx = mention.sent_idx start_token_idx = mention.start_token_idx end_token_idx = mention.end_token_idx head_token_idx = mention.head_token_idx rep = mention.rep # NOBUG: just use ner of the head token, should be correct ner = mention.head_token.ner tokens = [Token.from_token(token) for token in mention.tokens] return cls(sent_idx, start_token_idx, end_token_idx, head_token_idx, rep, ner, tokens)