Commit
•
b3d24c5
1
Parent(s):
7804055
Delete loading script
Browse files- ttc4900.py +0 -130
ttc4900.py
DELETED
@@ -1,130 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
-
#
|
4 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
# you may not use this file except in compliance with the License.
|
6 |
-
# You may obtain a copy of the License at
|
7 |
-
#
|
8 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
-
#
|
10 |
-
# Unless required by applicable law or agreed to in writing, software
|
11 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
-
# See the License for the specific language governing permissions and
|
14 |
-
# limitations under the License.
|
15 |
-
# Lint as: python3
|
16 |
-
"""TTC4900: A Benchmark Data for Turkish Text Categorization"""
|
17 |
-
|
18 |
-
|
19 |
-
import csv
|
20 |
-
|
21 |
-
import datasets
|
22 |
-
from datasets.tasks import TextClassification
|
23 |
-
|
24 |
-
|
25 |
-
logger = datasets.logging.get_logger(__name__)
|
26 |
-
|
27 |
-
|
28 |
-
_DESCRIPTION = """\
|
29 |
-
The data set is taken from kemik group
|
30 |
-
http://www.kemik.yildiz.edu.tr/
|
31 |
-
The data are pre-processed for the text categorization, collocations are found, character set is corrected, and so forth.
|
32 |
-
We named TTC4900 by mimicking the name convention of TTC 3600 dataset shared by the study http://journals.sagepub.com/doi/abs/10.1177/0165551515620551
|
33 |
-
|
34 |
-
If you use the dataset in a paper, please refer https://www.kaggle.com/savasy/ttc4900 as footnote and cite one of the papers as follows:
|
35 |
-
|
36 |
-
- A Comparison of Different Approaches to Document Representation in Turkish Language, SDU Journal of Natural and Applied Science, Vol 22, Issue 2, 2018
|
37 |
-
- A comparative analysis of text classification for Turkish language, Pamukkale University Journal of Engineering Science Volume 25 Issue 5, 2018
|
38 |
-
- A Knowledge-poor Approach to Turkish Text Categorization with a Comparative Analysis, Proceedings of CICLING 2014, Springer LNCS, Nepal, 2014.
|
39 |
-
"""
|
40 |
-
|
41 |
-
_CITATION = """\
|
42 |
-
@article{doi:10.5505/pajes.2018.15931,
|
43 |
-
author = {Yıldırım, Savaş and Yıldız, Tuğba},
|
44 |
-
title = {A comparative analysis of text classification for Turkish language},
|
45 |
-
journal = {Pamukkale Univ Muh Bilim Derg},
|
46 |
-
volume = {24},
|
47 |
-
number = {5},
|
48 |
-
pages = {879-886},
|
49 |
-
year = {2018},
|
50 |
-
doi = {10.5505/pajes.2018.15931},
|
51 |
-
note ={doi: 10.5505/pajes.2018.15931},
|
52 |
-
|
53 |
-
URL = {https://dx.doi.org/10.5505/pajes.2018.15931},
|
54 |
-
eprint = {https://dx.doi.org/10.5505/pajes.2018.15931}
|
55 |
-
}
|
56 |
-
"""
|
57 |
-
|
58 |
-
_LICENSE = "CC0: Public Domain"
|
59 |
-
_HOMEPAGE = "https://www.kaggle.com/savasy/ttc4900"
|
60 |
-
_DOWNLOAD_URL = "https://raw.githubusercontent.com/savasy/TurkishTextClassification/master"
|
61 |
-
_FILENAME = "7allV03.csv"
|
62 |
-
|
63 |
-
|
64 |
-
class TTC4900Config(datasets.BuilderConfig):
|
65 |
-
"""BuilderConfig for TTC4900"""
|
66 |
-
|
67 |
-
def __init__(self, **kwargs):
|
68 |
-
"""BuilderConfig for TTC4900.
|
69 |
-
Args:
|
70 |
-
**kwargs: keyword arguments forwarded to super.
|
71 |
-
"""
|
72 |
-
super(TTC4900Config, self).__init__(**kwargs)
|
73 |
-
|
74 |
-
|
75 |
-
class TTC4900(datasets.GeneratorBasedBuilder):
|
76 |
-
"""TTC4900: A Benchmark Data for Turkish Text Categorization"""
|
77 |
-
|
78 |
-
BUILDER_CONFIGS = [
|
79 |
-
TTC4900Config(
|
80 |
-
name="ttc4900",
|
81 |
-
version=datasets.Version("1.0.0"),
|
82 |
-
description="A Benchmark Data for Turkish Text Categorization",
|
83 |
-
),
|
84 |
-
]
|
85 |
-
|
86 |
-
def _info(self):
|
87 |
-
return datasets.DatasetInfo(
|
88 |
-
description=_DESCRIPTION,
|
89 |
-
features=datasets.Features(
|
90 |
-
{
|
91 |
-
"category": datasets.features.ClassLabel(
|
92 |
-
names=["siyaset", "dunya", "ekonomi", "kultur", "saglik", "spor", "teknoloji"]
|
93 |
-
),
|
94 |
-
"text": datasets.Value("string"),
|
95 |
-
}
|
96 |
-
),
|
97 |
-
supervised_keys=None,
|
98 |
-
# Homepage of the dataset for documentation
|
99 |
-
homepage=_HOMEPAGE,
|
100 |
-
# License for the dataset if available
|
101 |
-
license=_LICENSE,
|
102 |
-
# Citation for the dataset
|
103 |
-
citation=_CITATION,
|
104 |
-
task_templates=[TextClassification(text_column="text", label_column="category")],
|
105 |
-
)
|
106 |
-
|
107 |
-
def _split_generators(self, dl_manager):
|
108 |
-
"""Returns SplitGenerators."""
|
109 |
-
|
110 |
-
urls_to_download = {
|
111 |
-
"train": _DOWNLOAD_URL + "/" + _FILENAME,
|
112 |
-
}
|
113 |
-
downloaded_files = dl_manager.download(urls_to_download)
|
114 |
-
return [
|
115 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
116 |
-
]
|
117 |
-
|
118 |
-
def _generate_examples(self, filepath):
|
119 |
-
"""Generate TTC4900 examples."""
|
120 |
-
logger.info("⏳ Generating examples from = %s", filepath)
|
121 |
-
with open(filepath, encoding="utf-8") as f:
|
122 |
-
rdr = csv.reader(f, delimiter=",")
|
123 |
-
next(rdr)
|
124 |
-
rownum = 0
|
125 |
-
for row in rdr:
|
126 |
-
rownum += 1
|
127 |
-
yield rownum, {
|
128 |
-
"category": row[0],
|
129 |
-
"text": row[1],
|
130 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|