jordimas commited on
Commit
a7afeef
1 Parent(s): 7a641b6

Remove duplicates

Browse files
Files changed (2) hide show
  1. MemoriesProjectesLliures.tsv +2 -2
  2. raw/po-to-tsv.py +7 -5
MemoriesProjectesLliures.tsv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5136f1c76b48705de233b556ea899cb744c8086b2a15327f9050db4a9a770025
3
- size 86627621
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:47c8d2fa65ad83027de73d59681534f6ef667aaa8ee6ca133c82d7ba1da7da20
3
+ size 82174469
raw/po-to-tsv.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import polib
2
  import re
3
 
@@ -45,14 +46,15 @@ def generate_tsv(po_filename, output_filename):
45
  input_po = polib.pofile(po_filename)
46
  entries = 0
47
  words = 0
 
48
 
49
  with open(po_filename, "r") as source,\
50
  open(output_filename, "w") as output:
51
 
52
  for entry in input_po:
53
- src = _remove_accelerators(entry.msgid)
54
- trg = _remove_accelerators(entry.msgstr)
55
 
 
 
56
  src = _remove_tags(src)
57
  trg = _remove_tags(trg)
58
 
@@ -62,10 +64,10 @@ def generate_tsv(po_filename, output_filename):
62
  if SEPARATOR in src or SEPARATOR in trg:
63
  continue
64
 
65
- src = src.strip()
66
- trg = trg.strip()
67
-
68
 
 
69
  output.write(f"{src}{SEPARATOR}{trg}\n")
70
  words += len(src.split())
71
  entries += 1
 
1
+ # (c) 2022 Jordi Mas i Herandèz. Licensed under GPL 3.0.
2
  import polib
3
  import re
4
 
 
46
  input_po = polib.pofile(po_filename)
47
  entries = 0
48
  words = 0
49
+ srcs = set()
50
 
51
  with open(po_filename, "r") as source,\
52
  open(output_filename, "w") as output:
53
 
54
  for entry in input_po:
 
 
55
 
56
+ src = _remove_accelerators(entry.msgid.strip())
57
+ trg = _remove_accelerators(entry.msgstr.strip())
58
  src = _remove_tags(src)
59
  trg = _remove_tags(trg)
60
 
 
64
  if SEPARATOR in src or SEPARATOR in trg:
65
  continue
66
 
67
+ if src in srcs:
68
+ continue
 
69
 
70
+ srcs.add(src)
71
  output.write(f"{src}{SEPARATOR}{trg}\n")
72
  words += len(src.split())
73
  entries += 1