First upload
Browse files- .gitattributes +2 -0
- tmx/finnob.tmx +3 -0
- tmx/finsma.tmx +3 -0
- tmx/finsme.tmx +3 -0
- tmx/finsmn.tmx +3 -0
- tmx/finsms.tmx +3 -0
- tmx/nobsma.tmx +3 -0
- tmx/nobsme.tmx +3 -0
- tmx/nobsmj.tmx +3 -0
- tmx/smanob.tmx +3 -0
- tmx/smenob.tmx +3 -0
- tmx/smesma.tmx +3 -0
- tmx/smesmj.tmx +3 -0
- tmx/smesmn.tmx +3 -0
- tmx2cvs.py +99 -0
- tsv_source_target/finnob.tsv +3 -0
- tsv_source_target/finsma.tsv +3 -0
- tsv_source_target/finsme.tsv +3 -0
- tsv_source_target/finsmn.tsv +3 -0
- tsv_source_target/finsms.tsv +3 -0
- tsv_source_target/nobsma.tsv +3 -0
- tsv_source_target/nobsme.tsv +3 -0
- tsv_source_target/nobsmj.tsv +3 -0
- tsv_source_target/smanob.tsv +3 -0
- tsv_source_target/smenob.tsv +3 -0
- tsv_source_target/smesma.tsv +3 -0
- tsv_source_target/smesmj.tsv +3 -0
- tsv_source_target/smesmn.tsv +3 -0
.gitattributes
CHANGED
@@ -51,3 +51,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
51 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
52 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
53 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
51 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
52 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
53 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
54 |
+
*.tsv filter=lfs diff=lfs merge=lfs -text
|
55 |
+
*.tmx filter=lfs diff=lfs merge=lfs -text
|
tmx/finnob.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2dbd098ad15803967906db092ac2da153b3e69b44c53646591e017f36864b4fc
|
3 |
+
size 26806861
|
tmx/finsma.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:134be33e35c3e5f721d72008a1ebf8985cd7028de0dd6907807172f1368cdc3b
|
3 |
+
size 949188
|
tmx/finsme.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d96807dcb7970c6878a2afbebdf77e3c8806e5a5bfb5abbbe7c47923a9b4400b
|
3 |
+
size 38392106
|
tmx/finsmn.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9944adfd8c8d748c93ba8bc3c06e8501772c562051091e9e6dec253ea8d6a493
|
3 |
+
size 12297238
|
tmx/finsms.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fa46f1560414b998823ad7f5d15647e9ac618553bd64a36baedb77586babbe79
|
3 |
+
size 2407981
|
tmx/nobsma.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6bb01df0ccd03b8bdd90e932dbf0251c84daeae8c10dae5778cce772eb21735f
|
3 |
+
size 5786854
|
tmx/nobsme.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5d4ce16fa5777e0f681883adfb8b40cb3929e4397d6d9cab413ad4d967ac94c9
|
3 |
+
size 79453096
|
tmx/nobsmj.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fcb215d05357bbdfcf108c5cc7e3b5447ec3e4a12009f26fa86e5d7e2d46801c
|
3 |
+
size 4533171
|
tmx/smanob.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:306b0291a78a8ac7fae9197eba7ab148e0d1498289f5eaf5f989a1a8209401da
|
3 |
+
size 2277660
|
tmx/smenob.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ff0fa48855ffe9d15f160ae83f8c7ed5d84bcac8b738544d4422b8860975cef7
|
3 |
+
size 8970515
|
tmx/smesma.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3ff25e96534e4254e90b2a703688d11570ad891c556495e97e0f8542a88acab9
|
3 |
+
size 7878739
|
tmx/smesmj.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c551d7f2969c1570578a980a1007a0700397239f1a5d3f1e67712470d92a01fe
|
3 |
+
size 5880848
|
tmx/smesmn.tmx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:27a37b99c7c5401fd256d48073e31fb6112d805eb94f3918a3d61e91bd27ef7f
|
3 |
+
size 5155120
|
tmx2cvs.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import xmltodict
|
3 |
+
from sklearn.model_selection import train_test_split
|
4 |
+
import glob
|
5 |
+
import sys
|
6 |
+
|
7 |
+
filelist = glob.glob('tmx/*.tmx')
|
8 |
+
|
9 |
+
for tmxfile in filelist:
|
10 |
+
print(f"Starting to parse {tmxfile}")
|
11 |
+
|
12 |
+
verbose = 0
|
13 |
+
with open(tmxfile) as fd:
|
14 |
+
doc = xmltodict.parse(fd.read())
|
15 |
+
|
16 |
+
try:
|
17 |
+
#Use the first sentence pair to determine the target-source language
|
18 |
+
source = doc['tmx']['body']['tu'][0]['tuv'][0]['@xml:lang']
|
19 |
+
target = doc['tmx']['body']['tu'][1]['tuv'][1]['@xml:lang']
|
20 |
+
except:
|
21 |
+
source = doc['tmx']['body']['tu'][0]['tuv'][0]['@lang']
|
22 |
+
target = doc['tmx']['body']['tu'][1]['tuv'][1]['@lang']
|
23 |
+
|
24 |
+
# Extract content from xml/tmx
|
25 |
+
data=[]
|
26 |
+
errorcount = 0
|
27 |
+
for item in doc['tmx']['body']['tu'][:]:
|
28 |
+
trans = {}
|
29 |
+
valid = 1
|
30 |
+
trans[source] = item['tuv'][0]['seg']
|
31 |
+
trans[target] = item['tuv'][1]['seg']
|
32 |
+
if isinstance(trans[source],dict):
|
33 |
+
try:
|
34 |
+
trans[source] = trans[source]['#text']
|
35 |
+
trans[target] = trans[target]['#text']
|
36 |
+
except:
|
37 |
+
if verbose:
|
38 |
+
print("Dropping - Malformed XML")
|
39 |
+
valid = 0
|
40 |
+
|
41 |
+
if not trans[source] or not trans[target]:
|
42 |
+
valid = 0
|
43 |
+
if verbose:
|
44 |
+
print("Dropping source/target does not exist")
|
45 |
+
|
46 |
+
elif len(trans[source]) <= 1 or len(trans[target]) <=1:
|
47 |
+
valid = 0
|
48 |
+
if verbose:
|
49 |
+
print("Dropping - Partly empty entity")
|
50 |
+
|
51 |
+
elif '\t' in trans[source] or '\t' in trans[target]:
|
52 |
+
valid = 0
|
53 |
+
if verbose:
|
54 |
+
print("Dropping - Contains tabulator")
|
55 |
+
|
56 |
+
|
57 |
+
if valid == 1:
|
58 |
+
data.append(trans)
|
59 |
+
else:
|
60 |
+
errorcount += 1
|
61 |
+
|
62 |
+
# Create dataframe
|
63 |
+
df = pd.DataFrame(data)
|
64 |
+
|
65 |
+
# Shuffle
|
66 |
+
# df = df.sample(frac=1).reset_index(drop=True)
|
67 |
+
|
68 |
+
# Train - test - dev
|
69 |
+
#train, test = train_test_split(df, test_size=0.2)
|
70 |
+
#test, dev = train_test_split(test, test_size=0.5)
|
71 |
+
|
72 |
+
# Write the datasets to disk
|
73 |
+
#train.to_csv('train_tmp.tsv', index=False, header=False, sep='\t')
|
74 |
+
#test.to_csv('test_tmp.tsv', index=False, header=False, sep='\t')
|
75 |
+
#dev.to_csv('dev_tmp.tsv', index=False, header=False, sep='\t')
|
76 |
+
|
77 |
+
#Rename some languages
|
78 |
+
if source=="fi":
|
79 |
+
source="fin"
|
80 |
+
if target=="fi":
|
81 |
+
target="fin"
|
82 |
+
if source=="nb":
|
83 |
+
source="nob"
|
84 |
+
if target=="nb":
|
85 |
+
target="nob"
|
86 |
+
if source=="se":
|
87 |
+
source="sme"
|
88 |
+
if target=="se":
|
89 |
+
target="sme"
|
90 |
+
|
91 |
+
filename = "tsv_source_target/"+source+target+".tsv"
|
92 |
+
df.to_csv(filename, index=False, header=False, sep='\t')
|
93 |
+
|
94 |
+
#print(f"Finished writing train.tsv ({len(train)}), test.tsv ({len(test)}) and dev.tsv ({len(dev)}) to disk.")
|
95 |
+
print(f"Finished writing {filename} ({len(df)}) to disk.")
|
96 |
+
print(f"Totally {errorcount} errors")
|
97 |
+
|
98 |
+
|
99 |
+
|
tsv_source_target/finnob.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2d1e365665888dd8a45437d366ba347e918b246147c2662eaaf10d63e5cc168c
|
3 |
+
size 14747254
|
tsv_source_target/finsma.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fc6f8ee96ce2369f0e5a541ca12d741918ca23851e466cbd12357dbd923ef78e
|
3 |
+
size 524571
|
tsv_source_target/finsme.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5d87e55ff588e1b7891a63f547e5e87413cb0a791a233de459cc4eff541a0f9b
|
3 |
+
size 22793103
|
tsv_source_target/finsmn.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5d02afcc4316a4b03415e7ebcc10d57771f18c5ef4a8f357bb2481a1312da920
|
3 |
+
size 7419200
|
tsv_source_target/finsms.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f649db26d0d29f4a9d10b2143dce6cd621b55fbd0f8b664393b2a7e8efe70aca
|
3 |
+
size 1526331
|
tsv_source_target/nobsma.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3e342ce51e692644d18c3b51d33e921868e9f093aecc0487a6b9ab3b5b75cd77
|
3 |
+
size 3584241
|
tsv_source_target/nobsme.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7d1d55aa2697003f57c2a42b99366ae9f2c9e7ce9cd07afb7e02f1300de4fbe5
|
3 |
+
size 49399889
|
tsv_source_target/nobsmj.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8fe808de07094d0655cc2ac55ba13b2273b4dbf14c23c2be2690a3d0ca694067
|
3 |
+
size 2772500
|
tsv_source_target/smanob.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e9fffcc632fa184c23f53d919cb8cbb9be0ab598269ced1d7e2f3ba932d52961
|
3 |
+
size 1259461
|
tsv_source_target/smenob.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eae5e99a7fe8cf482e039ddcd726944765faf98b8cb3fc0c0b51c7fb214f5601
|
3 |
+
size 5279377
|
tsv_source_target/smesma.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7b54b6cebd36af21f804f04e33c468c768539d00c52edce90cd2406e3ceb375e
|
3 |
+
size 4625290
|
tsv_source_target/smesmj.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:470d4bb053144781a831c2fc3e81c03549ed4191b3f2ed289ea0bd77eced995c
|
3 |
+
size 3381053
|
tsv_source_target/smesmn.tsv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:23ae662992be6c5d4853a7596941902692fad8eeac36f759687bf34cc1aa7bb2
|
3 |
+
size 2832129
|