def keyphrase_label_from(candidate_span, element, generic_label=True):
    """Receive candidate_span and element from dataset and return keyphrase label"""
    label = 'NON-KEYPHRASE'
    if ('keyphrases' in element and 'keyphrase-id' in candidate_span and 
        candidate_span['keyphrase-id'] in element['keyphrases']):
        if not generic_label:
            label = element['keyphrases'][candidate_span['keyphrase-id']][
                'keyphrase-label']
        else:
            label = 'KEYPHRASE'
    return label
