Commit
·
8b6694e
1
Parent(s):
15a35eb
script
Browse files- russian_multidomain_spellcheck.py → RuSpellGold.py +47 -30
- data/aranea/split.csv +0 -0
- data/aranea/split.json +0 -0
- data/complete_test/test.json +0 -0
- data/literature/split.csv +0 -0
- data/literature/split.json +0 -0
- data/news/split.csv +0 -0
- data/news/split.json +0 -0
- data/social_media/split.csv +0 -0
- data/social_media/split.json +0 -0
- data/strategic_documents/split.csv +0 -0
- data/strategic_documents/split.json +0 -0
- data/test.csv +0 -0
russian_multidomain_spellcheck.py → RuSpellGold.py
RENAMED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import json
|
|
|
|
| 2 |
from typing import List
|
| 3 |
|
| 4 |
import datasets
|
|
@@ -17,17 +18,17 @@ _LICENSE = "apache-2.0"
|
|
| 17 |
|
| 18 |
|
| 19 |
class RuSpellGoldConfig(datasets.BuilderConfig):
|
| 20 |
-
"""BuilderConfig for
|
| 21 |
|
| 22 |
def __init__(self, data_urls, features, **kwargs):
|
| 23 |
-
"""BuilderConfig for
|
| 24 |
Args:
|
| 25 |
features: *list[string]*, list of the features that will appear in the
|
| 26 |
feature dict. Should not include "label".
|
| 27 |
data_urls: *dict[string]*, urls to download the zip file from.
|
| 28 |
**kwargs: keyword arguments forwarded to super.
|
| 29 |
"""
|
| 30 |
-
super(
|
| 31 |
self.data_urls = data_urls
|
| 32 |
self.features = features
|
| 33 |
|
|
@@ -36,23 +37,55 @@ class RuSpellGold(datasets.GeneratorBasedBuilder):
|
|
| 36 |
"""RuFacts dataset."""
|
| 37 |
|
| 38 |
BUILDER_CONFIGS = [
|
| 39 |
-
|
| 40 |
-
name="
|
| 41 |
data_urls={
|
| 42 |
-
"
|
| 43 |
-
"validation": "raw/validation.json",
|
| 44 |
-
"test": "raw/test.json",
|
| 45 |
},
|
| 46 |
-
features=["
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
),
|
| 48 |
]
|
| 49 |
|
| 50 |
def _info(self) -> datasets.DatasetInfo:
|
| 51 |
features = {
|
| 52 |
-
"
|
| 53 |
-
"
|
| 54 |
-
"
|
| 55 |
-
"label": datasets.features.ClassLabel(names=["consistent", "inconsistent"]),
|
| 56 |
}
|
| 57 |
return datasets.DatasetInfo(
|
| 58 |
features=datasets.Features(features),
|
|
@@ -66,27 +99,13 @@ class RuSpellGold(datasets.GeneratorBasedBuilder):
|
|
| 66 |
urls_to_download = self.config.data_urls
|
| 67 |
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
| 68 |
return [
|
| 69 |
-
datasets.SplitGenerator(
|
| 70 |
-
name=datasets.Split.TRAIN,
|
| 71 |
-
gen_kwargs={
|
| 72 |
-
"data_file": downloaded_files["train"],
|
| 73 |
-
"split": datasets.Split.TRAIN,
|
| 74 |
-
},
|
| 75 |
-
),
|
| 76 |
-
datasets.SplitGenerator(
|
| 77 |
-
name=datasets.Split.VALIDATION,
|
| 78 |
-
gen_kwargs={
|
| 79 |
-
"data_file": downloaded_files["validation"],
|
| 80 |
-
"split": datasets.Split.VALIDATION,
|
| 81 |
-
},
|
| 82 |
-
),
|
| 83 |
datasets.SplitGenerator(
|
| 84 |
name=datasets.Split.TEST,
|
| 85 |
gen_kwargs={
|
| 86 |
"data_file": downloaded_files["test"],
|
| 87 |
"split": datasets.Split.TEST,
|
| 88 |
},
|
| 89 |
-
)
|
| 90 |
]
|
| 91 |
|
| 92 |
def _generate_examples(self, data_file, split):
|
|
@@ -94,8 +113,6 @@ class RuSpellGold(datasets.GeneratorBasedBuilder):
|
|
| 94 |
key = 0
|
| 95 |
for line in f:
|
| 96 |
row = json.loads(line)
|
| 97 |
-
|
| 98 |
example = {feature: row[feature] for feature in self.config.features}
|
| 99 |
yield key, example
|
| 100 |
-
|
| 101 |
key += 1
|
|
|
|
| 1 |
import json
|
| 2 |
+
import pandas as pd
|
| 3 |
from typing import List
|
| 4 |
|
| 5 |
import datasets
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
class RuSpellGoldConfig(datasets.BuilderConfig):
|
| 21 |
+
"""BuilderConfig for RuSpellGold."""
|
| 22 |
|
| 23 |
def __init__(self, data_urls, features, **kwargs):
|
| 24 |
+
"""BuilderConfig for RuSpellGold.
|
| 25 |
Args:
|
| 26 |
features: *list[string]*, list of the features that will appear in the
|
| 27 |
feature dict. Should not include "label".
|
| 28 |
data_urls: *dict[string]*, urls to download the zip file from.
|
| 29 |
**kwargs: keyword arguments forwarded to super.
|
| 30 |
"""
|
| 31 |
+
super(RuSpellGoldConfig, self).__init__(version=datasets.Version("0.0.1"), **kwargs)
|
| 32 |
self.data_urls = data_urls
|
| 33 |
self.features = features
|
| 34 |
|
|
|
|
| 37 |
"""RuFacts dataset."""
|
| 38 |
|
| 39 |
BUILDER_CONFIGS = [
|
| 40 |
+
RuSpellGoldConfig(
|
| 41 |
+
name="aranea",
|
| 42 |
data_urls={
|
| 43 |
+
"test": "data/aranea/split.json",
|
|
|
|
|
|
|
| 44 |
},
|
| 45 |
+
features=["source", "correction", "domain"],
|
| 46 |
+
),
|
| 47 |
+
RuSpellGoldConfig(
|
| 48 |
+
name="literature",
|
| 49 |
+
data_urls={
|
| 50 |
+
"test": "data/literature/split.json",
|
| 51 |
+
},
|
| 52 |
+
features=["source", "correction", "domain"],
|
| 53 |
+
),
|
| 54 |
+
RuSpellGoldConfig(
|
| 55 |
+
name="news",
|
| 56 |
+
data_urls={
|
| 57 |
+
"test": "data/news/split.json",
|
| 58 |
+
},
|
| 59 |
+
features=["source", "correction", "domain"],
|
| 60 |
+
),
|
| 61 |
+
RuSpellGoldConfig(
|
| 62 |
+
name="social_media",
|
| 63 |
+
data_urls={
|
| 64 |
+
"test": "data/social_media/split.json",
|
| 65 |
+
},
|
| 66 |
+
features=["source", "correction", "domain"],
|
| 67 |
+
),
|
| 68 |
+
RuSpellGoldConfig(
|
| 69 |
+
name="strategic_documents",
|
| 70 |
+
data_urls={
|
| 71 |
+
"test": "data/strategic_documents/split.json",
|
| 72 |
+
},
|
| 73 |
+
features=["source", "correction", "domain"],
|
| 74 |
+
),
|
| 75 |
+
RuSpellGoldConfig(
|
| 76 |
+
name="complete_test",
|
| 77 |
+
data_urls={
|
| 78 |
+
"test": "data/complete_test/test.json",
|
| 79 |
+
},
|
| 80 |
+
features=["source", "correction", "domain"],
|
| 81 |
),
|
| 82 |
]
|
| 83 |
|
| 84 |
def _info(self) -> datasets.DatasetInfo:
|
| 85 |
features = {
|
| 86 |
+
"source": datasets.Value("string"),
|
| 87 |
+
"correction": datasets.Value("string"),
|
| 88 |
+
"domain": datasets.Value("string"),
|
|
|
|
| 89 |
}
|
| 90 |
return datasets.DatasetInfo(
|
| 91 |
features=datasets.Features(features),
|
|
|
|
| 99 |
urls_to_download = self.config.data_urls
|
| 100 |
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
| 101 |
return [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
datasets.SplitGenerator(
|
| 103 |
name=datasets.Split.TEST,
|
| 104 |
gen_kwargs={
|
| 105 |
"data_file": downloaded_files["test"],
|
| 106 |
"split": datasets.Split.TEST,
|
| 107 |
},
|
| 108 |
+
)
|
| 109 |
]
|
| 110 |
|
| 111 |
def _generate_examples(self, data_file, split):
|
|
|
|
| 113 |
key = 0
|
| 114 |
for line in f:
|
| 115 |
row = json.loads(line)
|
|
|
|
| 116 |
example = {feature: row[feature] for feature in self.config.features}
|
| 117 |
yield key, example
|
|
|
|
| 118 |
key += 1
|
data/aranea/split.csv
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/aranea/split.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/complete_test/test.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/literature/split.csv
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/literature/split.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/news/split.csv
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/news/split.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/social_media/split.csv
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/social_media/split.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/strategic_documents/split.csv
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/strategic_documents/split.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/test.csv
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|