svanhvit commited on
Commit
6e96c33
1 Parent(s): 12ef13a
Files changed (7) hide show
  1. iceErrorCorpus.py +22 -35
  2. test.csv +2 -2
  3. test.tsv +3 -0
  4. train.csv +2 -2
  5. train.tsv +3 -0
  6. valid.csv +2 -2
  7. valid.tsv +3 -0
iceErrorCorpus.py CHANGED
@@ -12,10 +12,9 @@ Icelandic GEC corpus.
12
  The Icelandic Error Corpus (IceEC) is a collection of texts in modern Icelandic annotated for mistakes related to spelling, grammar, and other issues. The texts are organized by genre, if which there are three: student essays, online news texts and Icelandic Wikipedia articles. Each mistake is marked according to error type using an error code, of which there are 253. The corpus consists of 4,046 texts with 56,956 categorized error instances. The corpus is divided into a development corpus, which comprises 90% of the corpus, and a test corpus, which comprises the other 10% of the corpus.
13
  """
14
 
15
- # TODO: Add a link to an official homepage for the dataset here
16
  _HOMEPAGE = "https://repository.clarin.is/repository/xmlui/handle/20.500.12537/105"
17
 
18
- CITATION = """
19
  @misc{20.500.12537/105,
20
  title = {Icelandic Error Corpus ({IceEC}) Version 1.1},
21
  author = {Ingason, Anton Karl and Stef{\'a}nsd{\'o}ttir, Lilja Bj{\"o}rk and Arnard{\'o}ttir, {\TH}{\'o}runn and Xu, Xindan},
@@ -24,35 +23,18 @@ CITATION = """
24
  copyright = {Creative Commons - Attribution 4.0 International ({CC} {BY} 4.0)},
25
  year = {2021} }
26
  """
27
-
28
- # TODO: Add the licence for the dataset here if you can find it
29
  _LICENSE = "CC BY 4.0"
30
 
31
- # TODO: Add link to the official dataset URLs here
32
- # The HuggingFace dataset library don't host the datasets but only point to the original files
33
- # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
34
  _URLS = {
35
- "train": "train.csv",
36
- "dev": "valid.csv",
37
- "test": "test.csv",
38
 
39
  }
40
 
41
- class Squad(datasets.GeneratorBasedBuilder):
42
- """SQUAD: The Stanford Question Answering Dataset. Version 1.1."""
43
-
44
- def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
45
- downloaded_files = dl_manager.download_and_extract(_URLS)
46
-
47
- return [
48
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
49
- datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
50
- datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["test"]}),
51
- ]
52
-
53
-
54
- # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
55
- class NewDataset(datasets.GeneratorBasedBuilder):
56
  """TODO: Short description of my dataset."""
57
 
58
  VERSION = datasets.Version("1.0.0")
@@ -74,6 +56,8 @@ class NewDataset(datasets.GeneratorBasedBuilder):
74
  ),
75
  ]
76
 
 
 
77
  def _info(self):
78
  # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
79
  if self.config.name == "iceErrorCorpus": # This is the name of the configuration selected in BUILDER_CONFIGS above
@@ -81,6 +65,7 @@ class NewDataset(datasets.GeneratorBasedBuilder):
81
  {
82
  "src": datasets.Value("string"),
83
  "tgt": datasets.Value("string"),
 
84
  }
85
  )
86
 
@@ -109,14 +94,13 @@ class NewDataset(datasets.GeneratorBasedBuilder):
109
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
110
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
111
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
112
- my_urls = _URLs[self.config.name]
113
- data_dir = dl_manager.download_and_extract(my_urls)
114
  return [
115
  datasets.SplitGenerator(
116
  name=datasets.Split.TRAIN,
117
  # These kwargs will be passed to _generate_examples
118
  gen_kwargs={
119
- "filepath": os.path.join(data_dir, "train.tsv"),
120
  "split": "train",
121
  },
122
  ),
@@ -124,7 +108,7 @@ class NewDataset(datasets.GeneratorBasedBuilder):
124
  name=datasets.Split.TEST,
125
  # These kwargs will be passed to _generate_examples
126
  gen_kwargs={
127
- "filepath": os.path.join(data_dir, "test.tsv"),
128
  "split": "test"
129
  },
130
  ),
@@ -132,7 +116,7 @@ class NewDataset(datasets.GeneratorBasedBuilder):
132
  name=datasets.Split.VALIDATION,
133
  # These kwargs will be passed to _generate_examples
134
  gen_kwargs={
135
- "filepath": os.path.join(data_dir, "valid.tsv"),
136
  "split": "dev",
137
  },
138
  ),
@@ -146,10 +130,13 @@ class NewDataset(datasets.GeneratorBasedBuilder):
146
  # The `key` is here for legacy reason (tfds) and is not important in itself.
147
 
148
  with open(filepath, encoding="utf-8") as f:
149
- for id_, row in enumerate(f):
150
- data = json.loads(row)
 
 
151
  if self.config.name == "iceErrorCorpus":
152
- yield id_, {
153
- "src": data["src"],
154
- "tgt": data["tgt"],
155
  }
 
 
12
  The Icelandic Error Corpus (IceEC) is a collection of texts in modern Icelandic annotated for mistakes related to spelling, grammar, and other issues. The texts are organized by genre, if which there are three: student essays, online news texts and Icelandic Wikipedia articles. Each mistake is marked according to error type using an error code, of which there are 253. The corpus consists of 4,046 texts with 56,956 categorized error instances. The corpus is divided into a development corpus, which comprises 90% of the corpus, and a test corpus, which comprises the other 10% of the corpus.
13
  """
14
 
 
15
  _HOMEPAGE = "https://repository.clarin.is/repository/xmlui/handle/20.500.12537/105"
16
 
17
+ _CITATION = """
18
  @misc{20.500.12537/105,
19
  title = {Icelandic Error Corpus ({IceEC}) Version 1.1},
20
  author = {Ingason, Anton Karl and Stef{\'a}nsd{\'o}ttir, Lilja Bj{\"o}rk and Arnard{\'o}ttir, {\TH}{\'o}runn and Xu, Xindan},
 
23
  copyright = {Creative Commons - Attribution 4.0 International ({CC} {BY} 4.0)},
24
  year = {2021} }
25
  """
26
+
27
+ # TODO: Add the licence for the dataset here if you can find it
28
  _LICENSE = "CC BY 4.0"
29
 
 
 
 
30
  _URLS = {
31
+ "train": "train.tsv",
32
+ "dev": "valid.tsv",
33
+ "test": "test.tsv",
34
 
35
  }
36
 
37
+ class iceErrorCorpus(datasets.GeneratorBasedBuilder):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  """TODO: Short description of my dataset."""
39
 
40
  VERSION = datasets.Version("1.0.0")
 
56
  ),
57
  ]
58
 
59
+ DEFAULT_CONFIG_NAME = "iceErrorCorpus" # It's not mandatory to have a default configuration. Just use one if it make sense.
60
+
61
  def _info(self):
62
  # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
63
  if self.config.name == "iceErrorCorpus": # This is the name of the configuration selected in BUILDER_CONFIGS above
 
65
  {
66
  "src": datasets.Value("string"),
67
  "tgt": datasets.Value("string"),
68
+ # These are the features of your dataset like images, labels ...
69
  }
70
  )
71
 
 
94
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
95
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
96
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
97
+ data_dir = dl_manager.download_and_extract(_URLS)
 
98
  return [
99
  datasets.SplitGenerator(
100
  name=datasets.Split.TRAIN,
101
  # These kwargs will be passed to _generate_examples
102
  gen_kwargs={
103
+ "filepath": data_dir["train"],
104
  "split": "train",
105
  },
106
  ),
 
108
  name=datasets.Split.TEST,
109
  # These kwargs will be passed to _generate_examples
110
  gen_kwargs={
111
+ "filepath": data_dir["test"],
112
  "split": "test"
113
  },
114
  ),
 
116
  name=datasets.Split.VALIDATION,
117
  # These kwargs will be passed to _generate_examples
118
  gen_kwargs={
119
+ "filepath": data_dir["dev"],
120
  "split": "dev",
121
  },
122
  ),
 
130
  # The `key` is here for legacy reason (tfds) and is not important in itself.
131
 
132
  with open(filepath, encoding="utf-8") as f:
133
+ key = 0
134
+ tsv_f = csv.reader(f, delimiter="\t", quoting=csv.QUOTE_NONE)
135
+ for row in tsv_f:
136
+ print(row)
137
  if self.config.name == "iceErrorCorpus":
138
+ yield key, {
139
+ "src": row[0],
140
+ "tgt": row[1],
141
  }
142
+ key += 1
test.csv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a076ab8a1828d2a5df9fd295e3055d34bc2acf4ad5021efd61d4cc9a9a08b64b
3
- size 1304324
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57e00bd6a3f45c59b67a4da8e767395d84fdc6c7245724c09f159a38b7085b71
3
+ size 1318536
test.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:066091e430aa1302e5694020ca3270a0a8f5b15692e039309e5175558a2eaa29
3
+ size 1297282
train.csv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:8bfc65bf7637a00ff6e77904d1ad9f13dde051c68ce5ba80519dce5058c95844
3
- size 13069777
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:616040d210408dafb16cc4e4a83cf8f8e5487dbb6efb815809bcdf66232da5ae
3
+ size 13218207
train.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6fbe25a0809372e9d18c16ea84cd80ae0167a473a3e4668a70feb25b35cac110
3
+ size 13003003
valid.csv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d72e99904d69141872f1151ba443bb6a7ffcc57576575b93b3ecb6f50a0c834c
3
- size 1222986
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:01e0456ed668b5655ade42a9b3f648dd2573683941f287c24130532fd25f6e61
3
+ size 1237256
valid.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0b4a359c468c16c9c64998c7ce9d37962fddbb291562fecf43caf08a57101a41
3
+ size 1217078