fix readme
Browse files
README.md
CHANGED
@@ -27,8 +27,9 @@ This dataset contains 5 different word analogy questions used in [Analogy Langua
|
|
27 |
| `u4` | 48/432 | 5,4,3 | 5 | [EnglishForEveryone](https://englishforeveryone.org/Topics/Analogies.html) |
|
28 |
| `google` | 50/500 | 4 | 2 | [Mikolov et al., (2013)](https://www.aclweb.org/anthology/N13-1090.pdf) |
|
29 |
| `bats` | 199/1799 | 4 | 3 | [Gladkova et al., (2016)](https://www.aclweb.org/anthology/N18-2017.pdf) |
|
30 |
-
| `
|
31 |
-
| `
|
|
|
32 |
|
33 |
## Dataset Structure
|
34 |
### Data Instances
|
|
|
27 |
| `u4` | 48/432 | 5,4,3 | 5 | [EnglishForEveryone](https://englishforeveryone.org/Topics/Analogies.html) |
|
28 |
| `google` | 50/500 | 4 | 2 | [Mikolov et al., (2013)](https://www.aclweb.org/anthology/N13-1090.pdf) |
|
29 |
| `bats` | 199/1799 | 4 | 3 | [Gladkova et al., (2016)](https://www.aclweb.org/anthology/N18-2017.pdf) |
|
30 |
+
| `semeval2012_relational_similarity` | 78/- | 3 | - | [relbert/semeval2012_relational_similarity](https://huggingface.co/datasets/relbert/semeval2012_relational_similarity) |
|
31 |
+
| `t_rex_relation_similarity` | 467/467 | 6 | - | [relbert/t_rex_relation_similarity](https://huggingface.co/datasets/relbert/t_rex_relation_similarity) |
|
32 |
+
| `conceptnet_relation_similarity` | 546/570 | 6 | - | [relbert/conceptnet_relation_similarity](https://huggingface.co/datasets/relbert/conceptnet_relation_similarity) |
|
33 |
|
34 |
## Dataset Structure
|
35 |
### Data Instances
|
add_new_analogy.py
CHANGED
@@ -14,41 +14,63 @@ from datasets import load_dataset
|
|
14 |
# f.write("\n".join([json.dumps(i) for i in analogy_data]))
|
15 |
|
16 |
|
17 |
-
# create analogy from `relbert/t_rex_relation_similarity`
|
18 |
-
data = load_dataset("relbert/t_rex_relation_similarity", "filter_unified.min_entity_1_max_predicate_100", split="test")
|
19 |
-
analogy_data = []
|
20 |
-
for i in data:
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
14 |
# f.write("\n".join([json.dumps(i) for i in analogy_data]))
|
15 |
|
16 |
|
17 |
+
# # create analogy from `relbert/t_rex_relation_similarity`
|
18 |
+
# data = load_dataset("relbert/t_rex_relation_similarity", "filter_unified.min_entity_1_max_predicate_100", split="test")
|
19 |
+
# analogy_data = []
|
20 |
+
# for i in data:
|
21 |
+
# if len(i['positives']) < 2:
|
22 |
+
# continue
|
23 |
+
# for m, (q, c) in enumerate(combinations(i['positives'], 2)):
|
24 |
+
# if m > 5:
|
25 |
+
# break
|
26 |
+
# negative = i['negatives']
|
27 |
+
# for n in range(6):
|
28 |
+
# seed(n)
|
29 |
+
# shuffle(negative)
|
30 |
+
# analogy_data.append({
|
31 |
+
# "stem": q, "choice": [c] + negative[:5], "answer": 0, "prefix": i["relation_type"]
|
32 |
+
# })
|
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]))
|
55 |
|
56 |
+
# create analogy from `relbert/conceptnet_relation_similarity`
|
57 |
+
for s in ['test', 'validation']:
|
58 |
+
data = load_dataset("relbert/conceptnet_relation_similarity", split=s)
|
59 |
+
analogy_data = []
|
60 |
+
for i in data:
|
61 |
+
if len(i['positives']) < 2:
|
62 |
+
continue
|
63 |
+
for m, (q, c) in enumerate(combinations(i['positives'], 2)):
|
64 |
+
if m > 5:
|
65 |
+
break
|
66 |
+
negative = i['negatives']
|
67 |
+
for n in range(6):
|
68 |
+
seed(n)
|
69 |
+
shuffle(negative)
|
70 |
+
analogy_data.append({
|
71 |
+
"stem": q, "choice": [c] + negative[:5], "answer": 0, "prefix": i["relation_type"]
|
72 |
+
})
|
73 |
+
print(len(analogy_data))
|
74 |
+
os.makedirs("dataset/conceptnet_relation_similarity", exist_ok=True)
|
75 |
+
with open(f"dataset/conceptnet_relation_similarity/{s if s == 'test' else 'valid'}.jsonl", "w") as f:
|
76 |
+
f.write("\n".join([json.dumps(i) for i in analogy_data]))
|
analogy_questions.py
CHANGED
@@ -5,7 +5,7 @@ import datasets
|
|
5 |
logger = datasets.logging.get_logger(__name__)
|
6 |
_DESCRIPTION = """[Analogy Question](https://aclanthology.org/2021.acl-long.280/)"""
|
7 |
_NAME = "analogy_questions"
|
8 |
-
_VERSION = "1.0.
|
9 |
_CITATION = """
|
10 |
@inproceedings{ushio-etal-2021-bert,
|
11 |
title = "{BERT} is to {NLP} what {A}lex{N}et is to {CV}: Can Pre-Trained Language Models Identify Analogies?",
|
@@ -34,7 +34,8 @@ _URLS = {
|
|
34 |
'sat_full': [f'{_URL}/sat/test.jsonl', f'{_URL}/sat/valid.jsonl'],
|
35 |
'u2': [f'{_URL}/u2/test.jsonl'],
|
36 |
'u4': [f'{_URL}/u4/test.jsonl'],
|
37 |
-
"t_rex_relation_similarity": [f'{_URL}/t_rex_relation_similarity/test.jsonl']
|
|
|
38 |
},
|
39 |
str(datasets.Split.VALIDATION): {
|
40 |
'bats': [f'{_URL}/bats/valid.jsonl'],
|
@@ -43,7 +44,8 @@ _URLS = {
|
|
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 |
|
|
|
5 |
logger = datasets.logging.get_logger(__name__)
|
6 |
_DESCRIPTION = """[Analogy Question](https://aclanthology.org/2021.acl-long.280/)"""
|
7 |
_NAME = "analogy_questions"
|
8 |
+
_VERSION = "1.0.6"
|
9 |
_CITATION = """
|
10 |
@inproceedings{ushio-etal-2021-bert,
|
11 |
title = "{BERT} is to {NLP} what {A}lex{N}et is to {CV}: Can Pre-Trained Language Models Identify Analogies?",
|
|
|
34 |
'sat_full': [f'{_URL}/sat/test.jsonl', f'{_URL}/sat/valid.jsonl'],
|
35 |
'u2': [f'{_URL}/u2/test.jsonl'],
|
36 |
'u4': [f'{_URL}/u4/test.jsonl'],
|
37 |
+
"t_rex_relation_similarity": [f'{_URL}/t_rex_relation_similarity/test.jsonl'],
|
38 |
+
"conceptnet_relation_similarity": [f'{_URL}/conceptnet_relation_similarity/test.jsonl']
|
39 |
},
|
40 |
str(datasets.Split.VALIDATION): {
|
41 |
'bats': [f'{_URL}/bats/valid.jsonl'],
|
|
|
44 |
'u2': [f'{_URL}/u2/valid.jsonl'],
|
45 |
'u4': [f'{_URL}/u4/valid.jsonl'],
|
46 |
"semeval2012_relational_similarity": [f'{_URL}/u4/valid.jsonl'],
|
47 |
+
"t_rex_relation_similarity": [f'{_URL}/t_rex_relation_similarity/valid.jsonl'],
|
48 |
+
"conceptnet_relation_similarity": [f'{_URL}/conceptnet_relation_similarity/valid.jsonl']
|
49 |
}
|
50 |
}
|
51 |
|
dataset/conceptnet_relation_similarity/test.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|
dataset/conceptnet_relation_similarity/valid.jsonl
ADDED
The diff for this file is too large to render.
See raw diff
|
|