-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_human_performance.py
More file actions
45 lines (35 loc) · 1.18 KB
/
get_human_performance.py
File metadata and controls
45 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
import json
import pandas as pd
from utils.data_utils import get_annotator_rationales
DATA_ROOT = 'data/e-SNLI'
test_df = pd.read_csv(f'{DATA_ROOT}/esnli_test.csv')
token_rationales, interaction_rationales = get_annotator_rationales(test_df)
for i, (token_rat,
interaction_rat) in enumerate(zip(token_rationales, interaction_rationales), 1):
"""
{
"pred_label": "contradiction",
"premise_rationales": [
"choir",
"songs",
"church"
],
"hypothesis_rationales": [
"ceiling"
]
},
"""
token_explanation = [{
'premise_rationales': rationale[0],
'hypothesis_rationales': rationale[1]
} for rationale in token_rat]
with open(f'explanations/annotator{i}_token.json', 'w') as f:
json.dump(token_explanation, f, indent=4)
interaction_explanation = [{
'pred_rationales': rationale
} for rationale in interaction_rat]
with open(f'explanations/annotator{i}_interaction.json', 'w') as f:
json.dump(interaction_explanation, f, indent=4)