(sentence_tokens, entities)
return new_tokens
Replaces an entity participating in the first relation in the graph with <e>

    :param sentence_tokens: 
    :param entities: 
    :return: the list of tokens
    >>> replace_entities(['where', 'are', 'the', 'nfl', 'redskins', 'from', '?'], [{'linkings': [],'tokens': ['Nfl', 'Redskins'],'type': 'NNP'}])
    ['where', 'are', 'the', '<e>', 'from', '?']
    >>> replace_entities(['what', 'was', 'vasco', 'nunez', 'de', 'balboa', 'original', 'purpose', 'of', 'his', 'journey', '?'], \
    [{'linkings': [],'tokens': ['Vasco', 'Nunez', 'De', 'Balboa'],'type': 'NNP'}, {'linkings': [],'tokens': ['journey'],'type': 'NN'}])
    ['what', 'was', '<e>', 'original', 'purpose', 'of', 'his', 'journey', '?']
    >>> replace_entities("What movies did Natalie Portman and Johnny Cash played in ?".split(), \
    [{'linkings': [],'tokens': ['Natalie', 'Portman'],'type': 'NNP'}, {'linkings': [],'tokens': ['Johnny', 'Cash'],'type': 'NNP'}])
    ['What', 'movies', 'did', '<e>', 'and', '<e>', 'played', 'in', '?']
    >>> replace_entities("what is the upper house of the house of representatives ?".split(), [{'linkings': [],'tokens': ['House', 'Of', "Representatives"],'type': 'NNP'}])
    ['what', 'is', 'the', 'upper', 'house', 'of', 'the', '<e>', '?']
    >>> replace_entities("Where is Mount McKinley ?".split(), [{'linkings': [],'tokens': ["Mount","McKinley"],'type': 'NNP'}])
    ['Where', 'is', '<e>', '?']
    >>> replace_entities(['what', 'are', 'the', 'names', 'of', 'michael', 'jackson', 'movies', '?'], \
    [{'linkings': [],'tokens': ['Michael', 'Jackson'],'type': 'NNP'}, {'linkings': [],'tokens': ['michael', 'jackson', 'movies'],'type': 'NNP'}])
    ['what', 'are', 'the', 'names', 'of', '<e>', 'movies', '?']
    >>> replace_entities(['what', 'are', 'the', 'names', 'of', 'michael', 'jackson'], \
    [{'linkings': [],'tokens': ['Michael', 'Jackson'],'type': 'NNP'}, {'linkings': [],'tokens': ['names'],'type': 'NNP'}])
    ['what', 'are', 'the', '<e>', 'of', '<e>']
Replaces an entity participating in the first relation in the graph with <e>
Replaces an entity participating in the first relation in the graph with <e >
def replace_entities(sentence_tokens, entities):
    """
    Replaces an entity participating in the first relation in the graph with <e>

    :param sentence_tokens: 
    :param entities: 
    :return: the list of tokens
    >>> replace_entities(['where', 'are', 'the', 'nfl', 'redskins', 'from', '?'], [{'linkings': [],'tokens': ['Nfl', 'Redskins'],'type': 'NNP'}])
    ['where', 'are', 'the', '<e>', 'from', '?']
    >>> replace_entities(['what', 'was', 'vasco', 'nunez', 'de', 'balboa', 'original', 'purpose', 'of', 'his', 'journey', '?'], \
    [{'linkings': [],'tokens': ['Vasco', 'Nunez', 'De', 'Balboa'],'type': 'NNP'}, {'linkings': [],'tokens': ['journey'],'type': 'NN'}])
    ['what', 'was', '<e>', 'original', 'purpose', 'of', 'his', 'journey', '?']
    >>> replace_entities("What movies did Natalie Portman and Johnny Cash played in ?".split(), \
    [{'linkings': [],'tokens': ['Natalie', 'Portman'],'type': 'NNP'}, {'linkings': [],'tokens': ['Johnny', 'Cash'],'type': 'NNP'}])
    ['What', 'movies', 'did', '<e>', 'and', '<e>', 'played', 'in', '?']
    >>> replace_entities("what is the upper house of the house of representatives ?".split(), [{'linkings': [],'tokens': ['House', 'Of', "Representatives"],'type': 'NNP'}])
    ['what', 'is', 'the', 'upper', 'house', 'of', 'the', '<e>', '?']
    >>> replace_entities("Where is Mount McKinley ?".split(), [{'linkings': [],'tokens': ["Mount","McKinley"],'type': 'NNP'}])
    ['Where', 'is', '<e>', '?']
    >>> replace_entities(['what', 'are', 'the', 'names', 'of', 'michael', 'jackson', 'movies', '?'], \
    [{'linkings': [],'tokens': ['Michael', 'Jackson'],'type': 'NNP'}, {'linkings': [],'tokens': ['michael', 'jackson', 'movies'],'type': 'NNP'}])
    ['what', 'are', 'the', 'names', 'of', '<e>', 'movies', '?']
    >>> replace_entities(['what', 'are', 'the', 'names', 'of', 'michael', 'jackson'], \
    [{'linkings': [],'tokens': ['Michael', 'Jackson'],'type': 'NNP'}, {'linkings': [],'tokens': ['names'],'type': 'NNP'}])
    ['what', 'are', 'the', '<e>', 'of', '<e>']
    """
    entities = [e for e in entities if e.get("type") != "NN"]
    entities = [[t.lower() for t in e.get("tokens", [])] for e in entities]
    new_tokens = sentence_tokens
    for entity in entities:
        new_tokens = replace_entity(new_tokens, entity)
    return new_tokens
def replace_entities ( sentence_tokens , entities ) : entities = [ e for e in entities if e . get ( "type" ) != "NN" ] entities = [ [ t . lower ( ) for t in e . get ( "tokens" , [ ] ) ] for e in entities ] new_tokens = sentence_tokens for entity in entities : new_tokens = replace_entity ( new_tokens , entity ) return new_tokens