holylovenia commited on
Commit
cccc887
1 Parent(s): 645dd0c

Upload filipino_gay_lang.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. filipino_gay_lang.py +115 -0
filipino_gay_lang.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ from typing import Dict, List, Tuple
3
+
4
+ import datasets
5
+ import pandas as pd
6
+
7
+ from seacrowd.utils.configs import SEACrowdConfig
8
+ from seacrowd.utils.constants import SCHEMA_TO_FEATURES, TASK_TO_SCHEMA, Tasks
9
+
10
+ # TODO: Add BibTeX citation
11
+ _CITATION = r"""\
12
+ @article{oco2015witchebelles,
13
+ author = {Oco, Nathaniel and Fajutagana, Raymart and Lim, Christine Mae and Mi{\~n}on, Judi Diane and Morano, Julie-Ann and Tinoco, Ryan Christian},
14
+ title = {Witchebelles Anata Magcharot kay Mudra na Nagsusuba si Akech: Developing a Rule-based Unidirectional Beki Lingo to Filipino Translator},
15
+ journal = {Journal of Sciences, Technology and Arts Research},
16
+ volume = {1},
17
+ number = {1},
18
+ year = {2015}
19
+ }
20
+ """
21
+
22
+ _LOCAL = False
23
+ _LANGUAGES = ["fil"]
24
+ _DATASETNAME = "filipino_gay_lang"
25
+ _DESCRIPTION = """\
26
+ The dataset contains 4000+ Filipino tweets in gay language or lingo also called swardspeak in slang terminology.
27
+ The tweet dataset was collected from February 2013 to November 2014 using the following commonly used gay words as filters: jinet ("hot"), ditey ("here"), imbyerna ("annoying"), etc.
28
+ The original paper makes use of the corpus to develop a gay language translator to understand the meaning of phrases using gay words in Filipino.
29
+ """
30
+
31
+ _HOMEPAGE = "https://github.com/imperialite/Philippine-Languages-Online-Corpora/tree/master/Tweets/Gay%20language"
32
+ _LICENSE = "CC-BY-SA 4.0"
33
+ _URLS = {
34
+ "gl_01": "https://github.com/imperialite/Philippine-Languages-Online-Corpora/raw/master/Tweets/Gay%20language/gl%20-%2001.xlsx",
35
+ "gl_02": "https://github.com/imperialite/Philippine-Languages-Online-Corpora/raw/master/Tweets/Gay%20language/gl%20-%2002.xlsx",
36
+ "gl_03": "https://github.com/imperialite/Philippine-Languages-Online-Corpora/raw/master/Tweets/Gay%20language/gl%20-%2003.xlsx",
37
+ }
38
+
39
+ _SUPPORTED_TASKS = [Tasks.SELF_SUPERVISED_PRETRAINING]
40
+ _SOURCE_VERSION = "1.0.0"
41
+ _SEACROWD_VERSION = "2024.06.20"
42
+
43
+
44
+ class FilipinoGayLangDataset(datasets.GeneratorBasedBuilder):
45
+ """This dataset contains 4000+ Filipino tweets in gay lingo/Beki/Swardspeak."""
46
+
47
+ SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
48
+ SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
49
+
50
+ SEACROWD_SCHEMA_NAME = TASK_TO_SCHEMA[_SUPPORTED_TASKS[0]].lower()
51
+
52
+ BUILDER_CONFIGS = [
53
+ SEACrowdConfig(
54
+ name=f"{_DATASETNAME}_source",
55
+ version=SOURCE_VERSION,
56
+ description=f"{_DATASETNAME} source schema",
57
+ schema="source",
58
+ subset_id=f"{_DATASETNAME}",
59
+ ),
60
+ SEACrowdConfig(
61
+ name=f"{_DATASETNAME}_seacrowd_{SEACROWD_SCHEMA_NAME}",
62
+ version=SEACROWD_VERSION,
63
+ description=f"{_DATASETNAME} SEACrowd schema",
64
+ schema=f"seacrowd_{SEACROWD_SCHEMA_NAME}",
65
+ subset_id=f"{_DATASETNAME}",
66
+ ),
67
+ ]
68
+
69
+ DEFAULT_CONFIG_NAME = f"{_DATASETNAME}_source"
70
+
71
+ def _info(self) -> datasets.DatasetInfo:
72
+ if self.config.schema == "source":
73
+ features = datasets.Features({"index": datasets.Value("string"), "text": datasets.Value("string")})
74
+ elif self.config.schema == f"seacrowd_{self.SEACROWD_SCHEMA_NAME}":
75
+ features = SCHEMA_TO_FEATURES[self.SEACROWD_SCHEMA_NAME.upper()]
76
+
77
+ return datasets.DatasetInfo(
78
+ description=_DESCRIPTION,
79
+ features=features,
80
+ homepage=_HOMEPAGE,
81
+ license=_LICENSE,
82
+ citation=_CITATION,
83
+ )
84
+
85
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
86
+ """Returns SplitGenerators."""
87
+
88
+ data_files = {
89
+ "gl_01": Path(dl_manager.download(_URLS["gl_01"])),
90
+ "gl_02": Path(dl_manager.download(_URLS["gl_02"])),
91
+ "gl_03": Path(dl_manager.download(_URLS["gl_03"])),
92
+ }
93
+
94
+ return [
95
+ datasets.SplitGenerator(
96
+ name=datasets.Split.TRAIN,
97
+ gen_kwargs={"filepath": [data_files["gl_01"], data_files["gl_02"], data_files["gl_03"]], "split": "train"},
98
+ )
99
+ ]
100
+
101
+ def _generate_examples(self, filepath: Path, split: str) -> Tuple[int, Dict]:
102
+ """Yields examples as (key, example) tuples."""
103
+
104
+ df = pd.concat((pd.read_excel(file) for file in filepath), ignore_index=True).reset_index()
105
+
106
+ if self.config.schema == "source":
107
+ for row in df.itertuples():
108
+ ex = {"index": str(row.index), "text": row.message}
109
+ yield row.index, ex
110
+ elif self.config.schema == f"seacrowd_{self.SEACROWD_SCHEMA_NAME}":
111
+ for row in df.itertuples():
112
+ ex = {"id": str(row.index), "text": row.message}
113
+ yield row.index, ex
114
+ else:
115
+ raise ValueError(f"Invalid config: {self.config.name}")