qanastek commited on
Commit
0d70363
1 Parent(s): 231659b

Update URL

Browse files
Files changed (1) hide show
  1. EMEA-V3.py +17 -25
EMEA-V3.py CHANGED
@@ -3,10 +3,8 @@
3
 
4
  """EMEA-V3 : European parallel translation corpus from the European Medicines Agency"""
5
 
6
- import os
7
- import csv
8
  import datasets
9
- from tqdm import tqdm
10
 
11
  logger = datasets.logging.get_logger(__name__)
12
 
@@ -65,7 +63,7 @@ class EMEA_V3(datasets.GeneratorBasedBuilder):
65
  def _split_generators(self, dl_manager):
66
 
67
  # Download the CSV
68
- data_dir = dl_manager.download_and_extract(_URL.format(self.config.name))
69
 
70
  return [
71
  datasets.SplitGenerator(
@@ -82,29 +80,23 @@ class EMEA_V3(datasets.GeneratorBasedBuilder):
82
  logger.info("⏳ Generating examples from = %s", filepath)
83
 
84
  key_ = 0
 
 
85
 
86
- with open(filepath, encoding="utf-8") as f:
87
 
88
- for id_, row in enumerate(csv.reader(f, delimiter=',')):
 
 
89
 
90
- if id_ == 0:
91
- continue
92
 
93
- print("*"*50)
94
- print(row)
95
- print(row[0])
96
- print(row[1])
97
- print(row[2])
98
- print("*"*50)
99
 
100
- # Get langue pair
101
- src, target = str(row[0]).split("-")
102
-
103
- yield key_, {
104
- "translation": {
105
- src: str(row[1]).strip(),
106
- target: str(row[2]).strip(),
107
- },
108
- }
109
-
110
- key_ += 1
 
3
 
4
  """EMEA-V3 : European parallel translation corpus from the European Medicines Agency"""
5
 
 
 
6
  import datasets
7
+ import pandas as pd
8
 
9
  logger = datasets.logging.get_logger(__name__)
10
 
 
63
  def _split_generators(self, dl_manager):
64
 
65
  # Download the CSV
66
+ data_dir = dl_manager.download(_URL.format(self.config.name))
67
 
68
  return [
69
  datasets.SplitGenerator(
 
80
  logger.info("⏳ Generating examples from = %s", filepath)
81
 
82
  key_ = 0
83
+
84
+ df = pd.read_csv(filepath, compression='gzip', header=0, sep=',')
85
 
86
+ for index, row in df.iterrows():
87
 
88
+ print(row['lang'])
89
+ print(row['source_text'])
90
+ print(row['target_text'])
91
 
92
+ # Get langue pair
93
+ src, target = str(row['lang']).split("-")
94
 
95
+ yield key_, {
96
+ "translation": {
97
+ src: str(row['source_text']).strip(),
98
+ target: str(row['target_text']).strip(),
99
+ },
100
+ }
101
 
102
+ key_ += 1