Skip to content
DeepForgeby svx
All problems
HardNLPnlp-221

Table Cell F1

Problem

Return the exact-match F1 over table cells given as [row, col, text] triples. A match requires row, column, and text to all be equal.

Duplicates collapse into sets, precision is matches / predicted cells, recall is matches / gold cells, and F1 = 2PR/(P+R). Return 1.0 when both sets are empty and 0.0 when either is empty or there are no matches.

Hint

Cells at the same position but with different text do not match.

Test cases

case 1
in: [[[0,0,"a"],[0,1,"b"]],[[0,0,"a"],[0,1,"b"]]]
expected: 1
case 2
in: [[[0,0,"a"],[0,1,"x"]],[[0,0,"a"],[0,1,"b"]]]
expected: 0.5
case 3
in: [[],[]]
expected: 1
case 4
in: [[[0,0,"a"]],[]]
expected: 0
case 5
in: [[[0,0,"a"]],[[0,0,"b"]]]
expected: 0
Starter codePython
def table_cell_f1(predicted, gold):
    # Your code here
    pass

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