Delete ntrex.py
Browse files
ntrex.py
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
import json
|
2 |
-
from itertools import chain
|
3 |
-
import datasets
|
4 |
-
|
5 |
-
logger = datasets.logging.get_logger(__name__)
|
6 |
-
_DESCRIPTION = """None"""
|
7 |
-
_NAME = "NTREX"
|
8 |
-
_VERSION = "1.0.0"
|
9 |
-
_CITATION = """
|
10 |
-
None
|
11 |
-
"""
|
12 |
-
|
13 |
-
_HOME_PAGE = "https://huggingface.co/datasets/xianf/NTREX"
|
14 |
-
_URL = f'https://huggingface.co/datasets/xianf/NTREX/blob/main'
|
15 |
-
_LANGUAGE = ['de', 'en', 'es', 'fr', 'it', 'id', 'hi', 'ar', 'ja', 'ko', 'pt', 'ru', 'th', 'tr', 'vi', 'zh', 'all']
|
16 |
-
_URLS = {
|
17 |
-
l: {
|
18 |
-
str(datasets.Split.TEST): [f'{_URL}/newstest2019.{l}.txt.jsonl'],
|
19 |
-
} for l in _LANGUAGE
|
20 |
-
}
|
21 |
-
|
22 |
-
|
23 |
-
class NTREXConfig(datasets.BuilderConfig):
|
24 |
-
"""BuilderConfig"""
|
25 |
-
|
26 |
-
def __init__(self, **kwargs):
|
27 |
-
"""BuilderConfig.
|
28 |
-
Args:
|
29 |
-
**kwargs: keyword arguments forwarded to super.
|
30 |
-
"""
|
31 |
-
super(NTREXConfig, self).__init__(**kwargs)
|
32 |
-
|
33 |
-
|
34 |
-
class NTREX(datasets.GeneratorBasedBuilder):
|
35 |
-
"""Dataset."""
|
36 |
-
|
37 |
-
BUILDER_CONFIGS = [
|
38 |
-
NTREXConfig(name=l, version=datasets.Version(_VERSION), description=f"{_DESCRIPTION} (language: {l})") for l in _LANGUAGE
|
39 |
-
]
|
40 |
-
|
41 |
-
def _split_generators(self, dl_manager):
|
42 |
-
downloaded_file = dl_manager.download_and_extract(_URLS[self.config.name])
|
43 |
-
return [datasets.SplitGenerator(name=i, gen_kwargs={"filepaths": downloaded_file[str(i)]})
|
44 |
-
for i in [datasets.Split.TEST]]
|
45 |
-
|
46 |
-
def _generate_examples(self, filepaths):
|
47 |
-
_key = 0
|
48 |
-
for filepath in filepaths:
|
49 |
-
logger.info(f"generating examples from = {filepath}")
|
50 |
-
with open(filepath, encoding="utf-8") as f:
|
51 |
-
_list = [i for i in f.read().split('\n') if len(i) > 0]
|
52 |
-
for i in _list:
|
53 |
-
data = json.loads(i)
|
54 |
-
yield _key, data
|
55 |
-
_key += 1
|
56 |
-
|
57 |
-
def _info(self):
|
58 |
-
return datasets.DatasetInfo(
|
59 |
-
description=_DESCRIPTION,
|
60 |
-
features=datasets.Features(
|
61 |
-
{
|
62 |
-
"text": datasets.Sequence(datasets.Value("string")),
|
63 |
-
}
|
64 |
-
),
|
65 |
-
supervised_keys=None,
|
66 |
-
homepage=_HOME_PAGE,
|
67 |
-
citation=_CITATION,
|
68 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|