juletxara commited on
Commit
01ae61b
1 Parent(s): a2ee458

modify script to include all jsonl fields in dataset

Browse files
Files changed (1) hide show
  1. euscrawl.py +25 -17
euscrawl.py CHANGED
@@ -52,6 +52,29 @@ _CITATION = """\
52
 
53
  _URL = "http://ixa.ehu.eus/euscrawl/files/euscrawl-v1-free-jsonl.tar.bz2"
54
  _FILEPATH = "euscrawl-v1-free-jsonl/euscrawl-v1.free.jsonl"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
 
57
  class EusCrawl(datasets.GeneratorBasedBuilder):
@@ -59,14 +82,7 @@ class EusCrawl(datasets.GeneratorBasedBuilder):
59
  return datasets.DatasetInfo(
60
  description=_DESCRIPTION,
61
  features=datasets.Features(
62
- {
63
- "id": datasets.Value("int32"),
64
- "title": datasets.Value("string"),
65
- "text": datasets.Value("string"),
66
- "source": datasets.Value("string"),
67
- "license": datasets.Value("string"),
68
- "url": datasets.Value("string"),
69
- },
70
  ),
71
  supervised_keys=None,
72
  homepage=_HOMEPAGE_URL,
@@ -87,13 +103,5 @@ class EusCrawl(datasets.GeneratorBasedBuilder):
87
  if filepath == _FILEPATH:
88
  for id, line in enumerate(file):
89
  data = json.loads(line)
90
-
91
  # defaut to empty string if field is missing
92
- yield id, {
93
- "id": id,
94
- "title": data.get("title", ""),
95
- "text": data.get("text", ""),
96
- "source": data.get("source", ""),
97
- "license": data.get("license", ""),
98
- "url": data.get("url", ""),
99
- }
 
52
 
53
  _URL = "http://ixa.ehu.eus/euscrawl/files/euscrawl-v1-free-jsonl.tar.bz2"
54
  _FILEPATH = "euscrawl-v1-free-jsonl/euscrawl-v1.free.jsonl"
55
+ KEYS = [
56
+ "title",
57
+ "opening",
58
+ "heading",
59
+ "text",
60
+ "extra",
61
+ "license",
62
+ "source",
63
+ "url",
64
+ "author",
65
+ "category",
66
+ "tags",
67
+ "revid",
68
+ "id",
69
+ "type",
70
+ "year",
71
+ "month",
72
+ "day",
73
+ "hour",
74
+ "minute",
75
+ "second",
76
+ "lang",
77
+ ]
78
 
79
 
80
  class EusCrawl(datasets.GeneratorBasedBuilder):
 
82
  return datasets.DatasetInfo(
83
  description=_DESCRIPTION,
84
  features=datasets.Features(
85
+ {key: datasets.Value("string") for key in KEYS},
 
 
 
 
 
 
 
86
  ),
87
  supervised_keys=None,
88
  homepage=_HOMEPAGE_URL,
 
103
  if filepath == _FILEPATH:
104
  for id, line in enumerate(file):
105
  data = json.loads(line)
 
106
  # defaut to empty string if field is missing
107
+ yield id, {key: data.get(key, "") for key in KEYS}