def graph_key_from_tag ( tag , entity_index ) : start_token = tag . get ( 'start_token' ) entity = tag . get ( 'entities' , [ ] ) [ entity_index ] return str ( start_token ) + '-' + entity . get ( 'key' ) + '-' + str ( entity . get ( 'confidence' ) )
how to use key to access tags in python
Returns a key from a tag entity
def graph_key_from_tag(tag, entity_index):
    """Returns a key from a tag entity

    Args:
        tag (tag) : this is the tag selected to get the key from
        entity_index (int) : this is the index of the tagged entity

    Returns:
        str : String representing the key for the given tagged entity.
    """
    start_token = tag.get('start_token')
    entity = tag.get('entities', [])[entity_index]
    return str(start_token) + '-' + entity.get('key') + '-' + str(entity.get('confidence'))