BayanDuygu commited on
Commit
8032a5a
1 Parent(s): 45aeafe

added dset script

Browse files
Files changed (1) hide show
  1. beyazperde-all-movies-reviews.py +87 -0
beyazperde-all-movies-reviews.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from itertools import chain
3
+ import datasets
4
+
5
+ logger = datasets.logging.get_logger(__name__)
6
+ _DESCRIPTION = """\
7
+ Movies sentiment analysis dataset for Turkish. Includes reviews for all movies of all time,\
8
+ crawled from popular Turkish movies website Beyazperde.com. All reviews are in Turkish.\
9
+ [BeyazPerde Top All Movie Reviews Dataset](https://github.com/turkish-nlp-suite/BeyazPerde-Movie-Reviews/)
10
+ """
11
+
12
+ _NAME = "beyazperde-all-movie-reviews"
13
+
14
+ _VERSION = "1.0.0"
15
+
16
+ _CITATION = """\
17
+ @inproceedings{altinok-2023-diverse,
18
+ title = "A Diverse Set of Freely Available Linguistic Resources for {T}urkish",
19
+ author = "Altinok, Duygu",
20
+ booktitle = "Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
21
+ month = jul,
22
+ year = "2023",
23
+ address = "Toronto, Canada",
24
+ publisher = "Association for Computational Linguistics",
25
+ url = "https://aclanthology.org/2023.acl-long.768",
26
+ pages = "13739--13750",
27
+ abstract = "This study presents a diverse set of freely available linguistic resources for Turkish natural language processing, including corpora, pretrained models and education material. Although Turkish is spoken by a sizeable population of over 80 million people, Turkish linguistic resources for natural language processing remain scarce. In this study, we provide corpora to allow practitioners to build their own applications and pretrained models that would assist industry researchers in creating quick prototypes. The provided corpora include named entity recognition datasets of diverse genres, including Wikipedia articles and supplement products customer reviews. In addition, crawling e-commerce and movie reviews websites, we compiled several sentiment analysis datasets of different genres. Our linguistic resources for Turkish also include pretrained spaCy language models. To the best of our knowledge, our models are the first spaCy models trained for the Turkish language. Finally, we provide various types of education material, such as video tutorials and code examples, that can support the interested audience on practicing Turkish NLP. The advantages of our linguistic resources are three-fold: they are freely available, they are first of their kind, and they are easy to use in a broad range of implementations. Along with a thorough description of the resource creation process, we also explain the position of our resources in the Turkish NLP world.",
28
+ }
29
+ """
30
+
31
+ _HOME_PAGE = "https://github.com/turkish-nlp-suite/BeyazPerde-Movie-Reviews/"
32
+ _URL = f'https://huggingface.co/datasets/turkish-nlp-suite/{_NAME}/raw/main/dataset'
33
+ _URLS = {
34
+ str(datasets.Split.TRAIN): [f'{_URL}/train.json'],
35
+ str(datasets.Split.TEST): [f'{_URL}/test.json'],
36
+ str(datasets.Split.VALIDATION): [f'{_URL}/valid.json'],
37
+ }
38
+
39
+
40
+ class BeyazperdeAllMovieReviewsConfig(datasets.BuilderConfig):
41
+ """BuilderConfig"""
42
+
43
+ def __init__(self, **kwargs):
44
+ """BuilderConfig.
45
+ Args:
46
+ **kwargs: keyword arguments forwarded to super.
47
+ """
48
+ super(BeyazperdeAllMovieReviewsConfig, self).__init__(**kwargs)
49
+
50
+
51
+ class BeyazperdeAllMovieReviews(datasets.GeneratorBasedBuilder):
52
+ """Dataset."""
53
+
54
+ BUILDER_CONFIGS = [
55
+ BeyazperdeTop300MovieReviewsConfig(name=_NAME, version=datasets.Version(_VERSION), description=_DESCRIPTION),
56
+ ]
57
+
58
+ def _split_generators(self, dl_manager):
59
+ downloaded_file = dl_manager.download_and_extract(_URLS)
60
+ return [datasets.SplitGenerator(name=i, gen_kwargs={"filepaths": downloaded_file[str(i)]})
61
+ for i in [datasets.Split.TRAIN, datasets.Split.TEST, datasets.Split.VALIDATION]]
62
+
63
+ def _generate_examples(self, filepaths):
64
+ _key = 0
65
+ for filepath in filepaths:
66
+ logger.info(f"generating examples from = {filepath}")
67
+ with open(filepath, encoding="utf-8") as f:
68
+ _list = [i for i in f.read().split('\n') if len(i) > 0]
69
+ for i in _list:
70
+ data = json.loads(i)
71
+ yield _key, data
72
+ _key += 1
73
+
74
+ def _info(self):
75
+ return datasets.DatasetInfo(
76
+ description=_DESCRIPTION,
77
+ features=datasets.Features(
78
+ {
79
+ "movie": datasets.Value("string"),
80
+ "text": datasets.Value("string"),
81
+ "star": datasets.Value("float"),
82
+ }
83
+ ),
84
+ supervised_keys=None,
85
+ homepage=_HOME_PAGE,
86
+ citation=_CITATION,
87
+ )