Updated script
Browse files- README.md +9 -9
- ciral-yoruba/qrels/qrels.ciral-yoruba-train.tsv +0 -2
- ciral.py +24 -5
README.md
CHANGED
@@ -39,15 +39,15 @@ This dataset repo contains only the queries and relevance judgements. The corpus
|
|
39 |
```
|
40 |
ciral_dataset = load_dataset("ciral/ciral", "hausa") #or swahili, somali, yoruba
|
41 |
|
42 |
-
for data in
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
```
|
52 |
|
53 |
|
|
|
39 |
```
|
40 |
ciral_dataset = load_dataset("ciral/ciral", "hausa") #or swahili, somali, yoruba
|
41 |
|
42 |
+
for data in ciral_data['train']: # or 'test'
|
43 |
+
query_id = data['query_id']
|
44 |
+
query = data['query']
|
45 |
+
pos_qrels = data['positive_passages']
|
46 |
+
neg_qrels = data['negative_passages']
|
47 |
+
|
48 |
+
for qrel in pos_qrels:
|
49 |
+
docid = qrel['docid']
|
50 |
+
text = qrel['text']
|
51 |
```
|
52 |
|
53 |
|
ciral-yoruba/qrels/qrels.ciral-yoruba-train.tsv
CHANGED
@@ -57,8 +57,6 @@
|
|
57 |
5 Q0 BBC#1268#1 0
|
58 |
5 Q0 BBC#1268#2 0
|
59 |
5 Q0 ALAROYE#961#2 0
|
60 |
-
11 Q0 BBC#1381#19 1
|
61 |
-
11 Q0 BBC#1381#20 1
|
62 |
11 Q0 BBC#4159#2 1
|
63 |
11 Q0 BBC#724#3 1
|
64 |
11 Q0 BBC#724#4 1
|
|
|
57 |
5 Q0 BBC#1268#1 0
|
58 |
5 Q0 BBC#1268#2 0
|
59 |
5 Q0 ALAROYE#961#2 0
|
|
|
|
|
60 |
11 Q0 BBC#4159#2 1
|
61 |
11 Q0 BBC#724#3 1
|
62 |
11 Q0 BBC#724#4 1
|
ciral.py
CHANGED
@@ -90,9 +90,16 @@ class CIRAL(datasets.GeneratorBasedBuilder):
|
|
90 |
{
|
91 |
"query_id": datasets.Value("string"),
|
92 |
"query": datasets.Value("string"),
|
93 |
-
"judgements": [{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
"docid": datasets.Value("string"),
|
95 |
-
"judgement": datasets.Value("string"),
|
96 |
"text": datasets.Value("string")}]
|
97 |
}
|
98 |
)
|
@@ -137,13 +144,25 @@ class CIRAL(datasets.GeneratorBasedBuilder):
|
|
137 |
queries = load_queries(query_file)
|
138 |
qrels = load_qrels(qrel_file)
|
139 |
for query_id in queries:
|
|
|
|
|
|
|
|
|
140 |
data = {}
|
141 |
data['query_id'] = query_id
|
142 |
data['query'] = queries[query_id]
|
143 |
-
data['
|
|
|
|
|
|
|
|
|
144 |
'docid': docid,
|
145 |
-
'judgement': judgement,
|
146 |
'text': docid2doc[docid]
|
147 |
-
} for docid
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
yield query_id, data
|
|
|
90 |
{
|
91 |
"query_id": datasets.Value("string"),
|
92 |
"query": datasets.Value("string"),
|
93 |
+
# "judgements": [{
|
94 |
+
# "docid": datasets.Value("string"),
|
95 |
+
# "judgement": datasets.Value("string"),
|
96 |
+
# "text": datasets.Value("string")}]
|
97 |
+
"positive_passages": [{
|
98 |
+
'docid': datasets.Value("string"),
|
99 |
+
'text': datasets.Value("string"),
|
100 |
+
}],
|
101 |
+
"negative_passages": [{
|
102 |
"docid": datasets.Value("string"),
|
|
|
103 |
"text": datasets.Value("string")}]
|
104 |
}
|
105 |
)
|
|
|
144 |
queries = load_queries(query_file)
|
145 |
qrels = load_qrels(qrel_file)
|
146 |
for query_id in queries:
|
147 |
+
|
148 |
+
positive_docids = [docid for docid, judgement in qrels[query_id].items() if judgement==1]
|
149 |
+
negative_docids = [docid for docid, judgement in qrels[query_id].items() if judgement==0]
|
150 |
+
|
151 |
data = {}
|
152 |
data['query_id'] = query_id
|
153 |
data['query'] = queries[query_id]
|
154 |
+
data['positive_passages'] = [{
|
155 |
+
'docid': docid,
|
156 |
+
'text': docid2doc[docid]
|
157 |
+
} for docid in positive_docids if docid in docid2doc]
|
158 |
+
data['negative_passages'] = [{
|
159 |
'docid': docid,
|
|
|
160 |
'text': docid2doc[docid]
|
161 |
+
} for docid in negative_docids if docid in docid2doc]
|
162 |
+
# data['judgements'] = [{
|
163 |
+
# 'docid': docid,
|
164 |
+
# 'judgement': judgement,
|
165 |
+
# 'text': docid2doc[docid]
|
166 |
+
# } for docid, judgement in qrels[query_id].items()]
|
167 |
|
168 |
yield query_id, data
|