Datasets:
ecoue
commited on
Commit
•
990acb6
1
Parent(s):
5dc576d
ignored some errors, ensured compatibility with python 3.7
Browse files- nordmann2023.py +2 -2
- utils.py +7 -9
nordmann2023.py
CHANGED
@@ -321,7 +321,7 @@ class Nordmann(
|
|
321 |
)
|
322 |
|
323 |
base_paths: Dict[str, str]
|
324 |
-
base_paths = dl_manager.download_and_extract(
|
325 |
url_or_urls=urls
|
326 |
)
|
327 |
|
@@ -340,7 +340,7 @@ class Nordmann(
|
|
340 |
|
341 |
return generators
|
342 |
|
343 |
-
def _generate_examples(
|
344 |
self,
|
345 |
candidates: Dict[str, Candidate],
|
346 |
base_paths: Dict[str, str]
|
|
|
321 |
)
|
322 |
|
323 |
base_paths: Dict[str, str]
|
324 |
+
base_paths = dl_manager.download_and_extract( # pyright: ignore
|
325 |
url_or_urls=urls
|
326 |
)
|
327 |
|
|
|
340 |
|
341 |
return generators
|
342 |
|
343 |
+
def _generate_examples( # pyright: ignore
|
344 |
self,
|
345 |
candidates: Dict[str, Candidate],
|
346 |
base_paths: Dict[str, str]
|
utils.py
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
from typing import Dict, TypeVar, Callable, List, Hashable,
|
2 |
from xml.etree import ElementTree
|
3 |
import unicodedata
|
4 |
from pathlib import Path
|
5 |
import re
|
6 |
|
7 |
Paths = Tuple[str, ...]
|
8 |
-
Language = Literal['de', 'en']
|
9 |
Translation = Dict[
|
10 |
Language, str
|
11 |
]
|
12 |
Sample = Dict[
|
13 |
-
Literal['translation'], Translation
|
14 |
]
|
15 |
SampleBatch = Dict[
|
16 |
-
Literal['translation'], List[Translation]
|
17 |
]
|
18 |
|
19 |
_H1 = TypeVar('_H1', bound=Hashable)
|
@@ -102,9 +102,7 @@ unicode_control_characters = (
|
|
102 |
def normalize(
|
103 |
strip_whitespaces: bool,
|
104 |
clean_control_characters: bool,
|
105 |
-
enforce_unicode_form: Optional[
|
106 |
-
Literal['NFC', 'NFKC', 'NFD', 'NFKD']
|
107 |
-
] = None
|
108 |
):
|
109 |
regex_pattern = re.compile(
|
110 |
pattern='[' + unicode_control_characters + ']+'
|
@@ -136,12 +134,12 @@ def normalize(
|
|
136 |
translation = dict_map(
|
137 |
input=translation, map_fn=lambda key, value: (
|
138 |
key, unicodedata.normalize(
|
139 |
-
enforce_unicode_form, value
|
140 |
)
|
141 |
)
|
142 |
)
|
143 |
|
144 |
-
sample['translation'] = translation
|
145 |
return sample
|
146 |
|
147 |
return normalize_fn
|
|
|
1 |
+
from typing import Dict, TypeVar, Callable, List, Hashable, Union, Optional, Tuple, Collection, Iterable
|
2 |
from xml.etree import ElementTree
|
3 |
import unicodedata
|
4 |
from pathlib import Path
|
5 |
import re
|
6 |
|
7 |
Paths = Tuple[str, ...]
|
8 |
+
Language = str # Literal['de', 'en']
|
9 |
Translation = Dict[
|
10 |
Language, str
|
11 |
]
|
12 |
Sample = Dict[
|
13 |
+
str, Translation # Literal['translation'], Translation
|
14 |
]
|
15 |
SampleBatch = Dict[
|
16 |
+
str, List[Translation] # Literal['translation'], List[Translation]
|
17 |
]
|
18 |
|
19 |
_H1 = TypeVar('_H1', bound=Hashable)
|
|
|
102 |
def normalize(
|
103 |
strip_whitespaces: bool,
|
104 |
clean_control_characters: bool,
|
105 |
+
enforce_unicode_form: Optional[str] = None # Optional[Literal['NFC', 'NFKC', 'NFD', 'NFKD']] = None
|
|
|
|
|
106 |
):
|
107 |
regex_pattern = re.compile(
|
108 |
pattern='[' + unicode_control_characters + ']+'
|
|
|
134 |
translation = dict_map(
|
135 |
input=translation, map_fn=lambda key, value: (
|
136 |
key, unicodedata.normalize(
|
137 |
+
enforce_unicode_form, value # pyright: ignore
|
138 |
)
|
139 |
)
|
140 |
)
|
141 |
|
142 |
+
sample['translation'] = translation # pyright: ignore
|
143 |
return sample
|
144 |
|
145 |
return normalize_fn
|