Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-115

Dependency Arc Accuracy

Problem

Return the fraction of tokens whose predicted head equals the gold head, where -1 marks the root.

Return 0.0 when the head list is empty.

Hint

zip the two head lists and compare each pair position by position.

Test cases

case 1
in: [[-1,0,1],[-1,0,2]]
expected: 0.6666666666666666
case 2
in: [[-1,0],[-1,0]]
expected: 1
case 3
in: [[],[]]
expected: 0
case 4
in: [[-1,0,1],[0,0,0]]
expected: 0.3333333333333333
Starter codePython
def arc_accuracy(gold_heads, predicted_heads):
    # Your code here
    pass

4 test cases · run your code against them in the editor