def is_keyphrase(labeled_candidate, tags, pos_sequences, tagging_notation=
    'BILOU'):
    """Receive labeled candidate and return true or false"""
    labels, candidate_spans = labeled_candidate
    start, end = candidate_spans['span']
    expected_tokens = end - start
    is_valid = False
    if tagging_notation == 'BIO' or tagging_notation == 'BILOU':
        postags = list(map(lambda t: t[1], tags[start:end]))
        labels_valid = list(map(lambda l: l[2:], filter(lambda l: l != 'O' and
            l[-len('NON-KEYPHRASE'):] != 'NON-KEYPHRASE', labels)))
        if len(labels_valid) == expected_tokens and postags == pos_sequences[
            candidate_spans['pos-seq-id']]['tags'] and len(set(labels_valid)
            ) == 1:
            is_valid = True
    return is_valid
