qanastek commited on
Commit
875004b
1 Parent(s): aa51e5e
Files changed (2) hide show
  1. ECDC.py +15 -10
  2. ECDC.py.lock +0 -0
ECDC.py CHANGED
@@ -3,6 +3,7 @@
3
 
4
  """ECDC : European parallel translation corpus from the European Medicines Agency"""
5
 
 
6
  import datasets
7
  import pandas as pd
8
 
@@ -56,8 +57,15 @@ class ECDC(datasets.GeneratorBasedBuilder):
56
  pair = (src, target)
57
  return datasets.DatasetInfo(
58
  description=_DESCRIPTION,
 
 
 
59
  features=datasets.Features(
60
- {"translation": datasets.features.Translation(languages=pair)}
 
 
 
 
61
  ),
62
  supervised_keys=(src, target),
63
  homepage="https://github.com/qanastek/ECDC/",
@@ -86,21 +94,18 @@ class ECDC(datasets.GeneratorBasedBuilder):
86
 
87
  key_ = 0
88
 
89
- df = pd.read_csv(filepath, compression='gzip', header=0, sep=',')
 
 
90
 
91
- for index, row in df.iterrows():
92
 
93
  # Get langue pair
94
  src, target = str(row['lang']).split("-")
95
 
96
- # print(src)
97
- # print(target)
98
- # print(row['lang'])
99
- # print(row['source_text'])
100
- # print(row['target_text'])
101
- # print()
102
-
103
  yield key_, {
 
 
104
  "translation": {
105
  src: str(row['source_text']).strip(),
106
  target: str(row['target_text']).strip(),
 
3
 
4
  """ECDC : European parallel translation corpus from the European Medicines Agency"""
5
 
6
+ import gzip
7
  import datasets
8
  import pandas as pd
9
 
 
57
  pair = (src, target)
58
  return datasets.DatasetInfo(
59
  description=_DESCRIPTION,
60
+ # features=datasets.Features(
61
+ # {"translation": datasets.features.Translation(languages=pair)}
62
+ # ),
63
  features=datasets.Features(
64
+ {
65
+ "doc_id": datasets.Value("string"),
66
+ "lang": datasets.Value("string"),
67
+ "translation": datasets.Translation(languages=pair),
68
+ },
69
  ),
70
  supervised_keys=(src, target),
71
  homepage="https://github.com/qanastek/ECDC/",
 
94
 
95
  key_ = 0
96
 
97
+ with open(filepath, 'rb') as fd:
98
+ gzip_fd = gzip.GzipFile(fileobj=fd)
99
+ df = pd.read_csv(gzip_fd)
100
 
101
+ for index, row in df.loc[df['lang'] == self.config.name].iterrows():
102
 
103
  # Get langue pair
104
  src, target = str(row['lang']).split("-")
105
 
 
 
 
 
 
 
 
106
  yield key_, {
107
+ "doc_id": row['key'],
108
+ "lang": row['lang'],
109
  "translation": {
110
  src: str(row['source_text']).strip(),
111
  target: str(row['target_text']).strip(),
ECDC.py.lock ADDED
File without changes