fix readme
Browse files- add_new_analogy.py +19 -0
- analogy_questions.py +2 -1
- dataset/t_rex_relation_similarity/valid.jsonl +0 -0
add_new_analogy.py
CHANGED
@@ -33,3 +33,22 @@ for i in data:
|
|
33 |
os.makedirs("dataset/t_rex_relation_similarity", exist_ok=True)
|
34 |
with open("dataset/t_rex_relation_similarity/test.jsonl", "w") as f:
|
35 |
f.write("\n".join([json.dumps(i) for i in analogy_data]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
os.makedirs("dataset/t_rex_relation_similarity", exist_ok=True)
|
34 |
with open("dataset/t_rex_relation_similarity/test.jsonl", "w") as f:
|
35 |
f.write("\n".join([json.dumps(i) for i in analogy_data]))
|
36 |
+
|
37 |
+
data = load_dataset("relbert/t_rex_relation_similarity", "filter_unified.min_entity_4_max_predicate_100", split="validation")
|
38 |
+
analogy_data = []
|
39 |
+
for i in data:
|
40 |
+
if len(i['positives']) < 5:
|
41 |
+
continue
|
42 |
+
for m, (q, c) in enumerate(combinations(i['positives'], 2)):
|
43 |
+
if m > 5:
|
44 |
+
break
|
45 |
+
negative = i['negatives']
|
46 |
+
for n in range(3):
|
47 |
+
seed(n)
|
48 |
+
shuffle(negative)
|
49 |
+
analogy_data.append({
|
50 |
+
"stem": q, "choice": [c] + negative[:5], "answer": 0, "prefix": i["relation_type"]
|
51 |
+
})
|
52 |
+
os.makedirs("dataset/t_rex_relation_similarity", exist_ok=True)
|
53 |
+
with open("dataset/t_rex_relation_similarity/valid.jsonl", "w") as f:
|
54 |
+
f.write("\n".join([json.dumps(i) for i in analogy_data]))
|
analogy_questions.py
CHANGED
@@ -42,7 +42,8 @@ _URLS = {
|
|
42 |
'sat': [f'{_URL}/sat/valid.jsonl'],
|
43 |
'u2': [f'{_URL}/u2/valid.jsonl'],
|
44 |
'u4': [f'{_URL}/u4/valid.jsonl'],
|
45 |
-
"semeval2012_relational_similarity": [f'{_URL}/u4/valid.jsonl']
|
|
|
46 |
}
|
47 |
}
|
48 |
|
|
|
42 |
'sat': [f'{_URL}/sat/valid.jsonl'],
|
43 |
'u2': [f'{_URL}/u2/valid.jsonl'],
|
44 |
'u4': [f'{_URL}/u4/valid.jsonl'],
|
45 |
+
"semeval2012_relational_similarity": [f'{_URL}/u4/valid.jsonl'],
|
46 |
+
"t_rex_relation_similarity": [f'{_URL}/t_rex_relation_similarity/valid.jsonl']
|
47 |
}
|
48 |
}
|
49 |
|
dataset/t_rex_relation_similarity/valid.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|