def evaluate_unlabeled_dependency(gold_file, punctuation):
    """
    Evaluate unlabeled accuracy per token.
    """
    md = Metadata.load_from_file('unlabeled_dependency')
    nn = taggers.load_network(md)
    reader = taggers.create_reader(md, gold_file)
    #reader.codify_sentences()
    
    logger = logging.getLogger("Logger")
    logger.debug('Loaded network')
    logger.debug(nn.description())
    logger.info('Starting test...')
    hits = 0
    num_tokens = 0
    sentence_hits = 0
    num_sentences = 0
    
    for sent, heads in zip(reader.sentences, reader.heads):
        
        sent_codified = reader.codify_sentence(sent)
        answer = nn.tag_sentence(sent_codified)
        correct_sentence = True
            
        for i, (net_tag, gold_tag) in enumerate(zip(answer, heads)):
            
            token = sent[i]
            # detect punctuation
            if punctuation and is_punctuation(token):
                continue
            
            if net_tag == gold_tag or (gold_tag == i and net_tag == len(sent)):
                hits += 1
            else:
                correct_sentence = False
            
            num_tokens += 1
            
        if correct_sentence:
            sentence_hits += 1
        num_sentences += 1
        
    accuracy = float(hits) / num_tokens
    sent_accuracy = 100 * float(sentence_hits) / num_sentences
    print('%d hits out of %d' % (hits, num_tokens))
    print('%d sentences completely correct (%f%%)' % (sentence_hits, sent_accuracy))
    print('Accuracy: %f%%' % (100 * accuracy))
dataset/ETHPy150Open erickrf/nlpnet/bin/nlpnet-test.py/evaluate_unlabeled_dependency/original