Datasets:

Languages:
Polish
ArXiv:
License:
asawczyn commited on
Commit
4557dcf
·
verified ·
1 Parent(s): 2779d97

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. PUGG_IR.py +93 -0
  2. README.md +4 -14
  3. qrels/test.tsv +0 -0
PUGG_IR.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+
4
+ import datasets
5
+
6
+ logger = datasets.logging.get_logger(__name__)
7
+
8
+ _CORPUS = "corpus"
9
+ _QUERIES = "queries"
10
+ _QRELS = "qrels"
11
+
12
+ URL = ""
13
+ _URLs = {
14
+ _CORPUS: f"corpus.jsonl",
15
+ _QUERIES: f"queries.jsonl",
16
+ _QRELS: f"qrels/test.tsv",
17
+ }
18
+
19
+
20
+ class PuggIr(datasets.GeneratorBasedBuilder):
21
+
22
+ BUILDER_CONFIGS = [
23
+ datasets.BuilderConfig(
24
+ name=_CORPUS,
25
+ ),
26
+ datasets.BuilderConfig(
27
+ name=_QUERIES,
28
+ ),
29
+ datasets.BuilderConfig(
30
+ name=_QRELS,
31
+ ),
32
+ ]
33
+
34
+ def _info(self):
35
+ if self.config.name == _CORPUS:
36
+ features = datasets.Features(
37
+ {
38
+ "_id": datasets.Value("string"),
39
+ "title": datasets.Value("string"),
40
+ "text": datasets.Value("string"),
41
+ }
42
+ )
43
+ elif self.config.name == _QUERIES:
44
+ features = datasets.Features(
45
+ {
46
+ "_id": datasets.Value("string"),
47
+ "query": datasets.Value("string"),
48
+ }
49
+ )
50
+ elif self.config.name == _QRELS:
51
+ features = datasets.Features(
52
+ {
53
+ "query-id": datasets.Value("string"),
54
+ "corpus-id": datasets.Value("string"),
55
+ "score": datasets.Value("int32"),
56
+ }
57
+ )
58
+
59
+ return datasets.DatasetInfo(
60
+ features=features,
61
+ )
62
+
63
+ def _split_generators(self, dl_manager):
64
+ """Returns SplitGenerators."""
65
+ my_urls = _URLs[self.config.name]
66
+ data_dir = dl_manager.download_and_extract(my_urls)
67
+
68
+ return [
69
+ datasets.SplitGenerator(
70
+ name=datasets.Split.TEST,
71
+ gen_kwargs={"filepath": data_dir},
72
+ ),
73
+ ]
74
+
75
+ def _generate_examples(self, filepath):
76
+ """Yields examples."""
77
+ if self.config.name in [_CORPUS, _QUERIES]:
78
+ with open(filepath, encoding="utf-8") as f:
79
+ for i, line in enumerate(f):
80
+ data = json.loads(line)
81
+ yield i, data
82
+
83
+ elif self.config.name == _QRELS:
84
+ with open(filepath, encoding="utf-8") as f:
85
+ for i, line in enumerate(f):
86
+ if i == 0:
87
+ continue # Skip header
88
+ query_id, corpus_id, score = line.strip().split("\t")
89
+ yield i, {
90
+ "query-id": query_id,
91
+ "corpus-id": corpus_id,
92
+ "score": int(score),
93
+ }
README.md CHANGED
@@ -19,19 +19,6 @@ task_ids:
19
  pretty_name: 'PUGG: IR dataset for Polish'
20
  tags:
21
  - wikipedia
22
- configs:
23
- - config_name: corpus
24
- data_files:
25
- - split: test
26
- path: corpus.jsonl
27
- - config_name: queries
28
- data_files:
29
- - split: test
30
- path: queries.jsonl
31
- - config_name: qrels
32
- data_files:
33
- - split: test
34
- path: qrels/test.jsonl
35
  ---
36
  # PUGG: KBQA, MRC, IR Dataset for Polish
37
 
@@ -64,7 +51,7 @@ Authored by:
64
 
65
  The dataset is available in the following repositories:
66
 
67
- * [General](https://huggingface.co/datasets/clarin-pl/PUGG_KBQA) - contains all tasks (KBQA, MRC, IR)
68
 
69
  For more straightforward usage, the tasks are also available in separate repositories:
70
 
@@ -76,6 +63,9 @@ The knowledge graph for KBQA task is available in the following repository:
76
 
77
  * [Knowledge Graph](https://huggingface.co/datasets/clarin-pl/PUGG_KG)
78
 
 
 
 
79
  ## Links
80
 
81
  * Code:
 
19
  pretty_name: 'PUGG: IR dataset for Polish'
20
  tags:
21
  - wikipedia
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  ---
23
  # PUGG: KBQA, MRC, IR Dataset for Polish
24
 
 
51
 
52
  The dataset is available in the following repositories:
53
 
54
+ * [General](https://huggingface.co/datasets/clarin-pl/PUGG_KBQA) - contains all tasks (KBQA, MRC, IR*)
55
 
56
  For more straightforward usage, the tasks are also available in separate repositories:
57
 
 
63
 
64
  * [Knowledge Graph](https://huggingface.co/datasets/clarin-pl/PUGG_KG)
65
 
66
+ Note: If you want to utilize the IR task in the BEIR format (`qrels` in `.tsv` format), please
67
+ download the [IR](https://huggingface.co/datasets/clarin-pl/PUGG_IR) repository.
68
+
69
  ## Links
70
 
71
  * Code:
qrels/test.tsv ADDED
The diff for this file is too large to render. See raw diff