Upload ru_anglicism.py
Browse files- ru_anglicism.py +52 -0
ru_anglicism.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
from typing import List
|
3 |
+
|
4 |
+
import datasets
|
5 |
+
|
6 |
+
|
7 |
+
_DESCRIPTION = "Russian dataset for detection and substraction of anglicisms."
|
8 |
+
_URLS = {
|
9 |
+
"train": "data/train.jsonl",
|
10 |
+
"test": "data/test.jsonl"
|
11 |
+
}
|
12 |
+
_LICENSE = "apache-2.0"
|
13 |
+
|
14 |
+
|
15 |
+
class GazetaDataset(datasets.GeneratorBasedBuilder):
|
16 |
+
"""Gazeta Dataset"""
|
17 |
+
|
18 |
+
VERSION = datasets.Version("0.2.0")
|
19 |
+
|
20 |
+
BUILDER_CONFIGS = [
|
21 |
+
datasets.BuilderConfig(name="default", version=VERSION, description=""),
|
22 |
+
]
|
23 |
+
|
24 |
+
DEFAULT_CONFIG_NAME = "default"
|
25 |
+
|
26 |
+
def _info(self):
|
27 |
+
features = datasets.Features(
|
28 |
+
{
|
29 |
+
"word": datasets.Value("string"),
|
30 |
+
"form": datasets.Value("string"),
|
31 |
+
"sentence": datasets.Value("string"),
|
32 |
+
"paraphrase": datasets.Value("string")
|
33 |
+
}
|
34 |
+
)
|
35 |
+
return datasets.DatasetInfo(
|
36 |
+
description=_DESCRIPTION,
|
37 |
+
features=features,
|
38 |
+
supervised_keys=("sentence", "paraphrase"),
|
39 |
+
)
|
40 |
+
|
41 |
+
def _split_generators(self, dl_manager):
|
42 |
+
downloaded_files = dl_manager.download_and_extract(_URLS)
|
43 |
+
return [
|
44 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
45 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]})
|
46 |
+
]
|
47 |
+
|
48 |
+
def _generate_examples(self, filepath):
|
49 |
+
with open(filepath, encoding="utf-8") as f:
|
50 |
+
for id_, row in enumerate(f):
|
51 |
+
data = json.loads(row)
|
52 |
+
yield id_, data
|