Datasets:

Languages:
English
Multilinguality:
en-sv
en-pl
en-hu
Size Categories:
100K<n<1M
Language Creators:
found
Source Datasets:
extended
Tags:
License:
File size: 1,665 Bytes
bd563e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a9d8f74
bd563e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import re
import pandas as pd
from tqdm import tqdm 
from bs4 import BeautifulSoup

# https://wt-public.emm4u.eu/Resources/ECDC-TM/2012_10_Terms-of-Use_ECDC-TM.pdf

INPUT_TMX = "ECDC.tmx"

print("⌛ Load TMX...")

tree = BeautifulSoup(open(INPUT_TMX,"r"), features="lxml")

print("⚗️ Parse content")
sentences = []
for tu in tqdm(tree.findAll("tu")):
    langs = {}
    for tuv in tu.findAll("tuv"):
        text = re.sub("\s+", " ", tuv.seg.text.replace("\n"," "))
        langs[tuv["xml:lang"].lower()] = text
    sentences.append(langs)

content = []

print("⚙️ Convert to CSV")
# For each sentences
for idx, sentence in tqdm(enumerate(sentences)):

    # For each language
    for lang in sentence:

        # Pass english
        if lang == "en" or len(sentence[lang].replace(" ","")) <= 0:
            continue
        
        # Add row
        content.append({
            'key': "doc_" + str(idx),
            'lang': "en-" + lang,
            'source_text': sentence["en"],
            'target_text': sentence[lang]
        })

df = pd.DataFrame({
    'key': [],
    'lang': [],
    'source_text': [],
    'target_text': []
})
df = df.append(content)

# Sort by language pair
df = df.sort_values(by=['lang'], ascending=True)

print("💾 Save as CSV and GZ")
df.to_csv("ECDC.csv", index=False)
df.to_csv("ECDC.csv.gz", index=False, compression="gzip")

uniq_elements = list(set(df['lang'].unique()))
l = open("langs.txt","w")
l.write("\n".join(uniq_elements))
l.close()


uniq_elements = df.groupby('lang').count()
l = open("stats.md","w")
l.write(str(uniq_elements))
l.close()