Datasets:

Languages:
Kawi
ArXiv:
License:
holylovenia commited on
Commit
b98c61f
1 Parent(s): 7b3799b

Upload ojw.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. ojw.py +140 -0
ojw.py ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2022 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
+
16
+ """
17
+ Dataloader implementation for Old Javanese Wordnet dataset.
18
+ """
19
+
20
+ from pathlib import Path
21
+ from typing import Dict, List, Tuple
22
+
23
+ import datasets
24
+ import pandas as pd
25
+
26
+ from nusacrowd.utils.configs import NusantaraConfig
27
+
28
+ _CITATION = """\
29
+ @inproceedings{moeljadi-aminullah-2020-building,
30
+ title = "Building the Old {J}avanese {W}ordnet",
31
+ author = "Moeljadi, David and
32
+ Aminullah, Zakariya Pamuji",
33
+ booktitle = "Proceedings of the 12th Language Resources and Evaluation Conference",
34
+ month = may,
35
+ year = "2020",
36
+ address = "Marseille, France",
37
+ publisher = "European Language Resources Association",
38
+ url = "https://aclanthology.org/2020.lrec-1.359",
39
+ pages = "2940--2946",
40
+ abstract = "This paper discusses the construction and the ongoing development of the Old Javanese Wordnet.
41
+ The words were extracted from the digitized version of the Old Javanese{--}English Dictionary (Zoetmulder, 1982).
42
+ The wordnet is built using the {`}expansion{'} approach (Vossen, 1998), leveraging on the Princeton Wordnet{'}s
43
+ core synsets and semantic hierarchy, as well as scientific names. The main goal of our project was to produce a
44
+ high quality, human-curated resource. As of December 2019, the Old Javanese Wordnet contains 2,054 concepts or
45
+ synsets and 5,911 senses. It is released under a Creative Commons Attribution 4.0 International License
46
+ (CC BY 4.0). We are still developing it and adding more synsets and senses. We believe that the lexical data
47
+ made available by this wordnet will be useful for a variety of future uses such as the development of Modern
48
+ Javanese Wordnet and many language processing tasks and linguistic research on Javanese.",
49
+ language = "English",
50
+ ISBN = "979-10-95546-34-4",
51
+ }
52
+ """
53
+
54
+ _DATASETNAME = "ojw"
55
+
56
+ _DESCRIPTION = """\
57
+ This dataset contains Old Javanese written language aimed to build a machine readable sources for Old Javanese: providing a wordnet for the language (Moeljadi et. al., 2020).
58
+ """
59
+
60
+
61
+ _HOMEPAGE = "https://github.com/davidmoeljadi/OJW"
62
+
63
+
64
+ _LICENSE = "Creative Commons Attribution 4.0 International (CC BY 4.0)"
65
+
66
+
67
+ _URLS = {
68
+ _DATASETNAME: "https://raw.githubusercontent.com/davidmoeljadi/OJW/master/wn-kaw.tab",
69
+ }
70
+
71
+ _SUPPORTED_TASKS = []
72
+
73
+ _SOURCE_VERSION = "1.0.0"
74
+
75
+ _NUSANTARA_VERSION = "1.0.0"
76
+
77
+ _LOCAL = False
78
+
79
+ _LANGUAGES = ["kaw"]
80
+
81
+
82
+ class OJW(datasets.GeneratorBasedBuilder):
83
+ """Old Javanese Wordnet (OJW) is a dataset that contains Old Javanese words and each variants of the words if available.
84
+ The dataset consists of 5038 rows and three columns: synset, tlemma, and tvariants."""
85
+
86
+ SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
87
+ NUSANTARA_VERSION = datasets.Version(_NUSANTARA_VERSION)
88
+
89
+ BUILDER_CONFIGS = [
90
+ NusantaraConfig(
91
+ name="ojw_source",
92
+ version=SOURCE_VERSION,
93
+ description="ojw source schema",
94
+ schema="source",
95
+ subset_id="ojw",
96
+ ),
97
+ ]
98
+
99
+ DEFAULT_CONFIG_NAME = "ojw_source"
100
+
101
+ def _info(self) -> datasets.DatasetInfo:
102
+ if self.config.schema == "source":
103
+ features = datasets.Features({"synset": datasets.Value("string"), "tlemma": datasets.Value("string"), "tvariants": datasets.Value("string")})
104
+
105
+ return datasets.DatasetInfo(
106
+ description=_DESCRIPTION,
107
+ features=features,
108
+ homepage=_HOMEPAGE,
109
+ license=_LICENSE,
110
+ citation=_CITATION,
111
+ )
112
+
113
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
114
+ """Returns SplitGenerators."""
115
+
116
+ urls = _URLS[_DATASETNAME]
117
+ data_dir = dl_manager.download(urls)
118
+
119
+ return [
120
+ datasets.SplitGenerator(
121
+ name=datasets.Split.TRAIN,
122
+ gen_kwargs={
123
+ "filepath": data_dir,
124
+ "split": "train",
125
+ },
126
+ ),
127
+ ]
128
+
129
+ def _generate_examples(self, filepath: Path, split: str) -> Tuple[int, Dict]:
130
+ """Yields examples as (key, example) tuples."""
131
+
132
+ df = pd.read_csv(filepath, sep="\t", names=["synset", "tlemma", "tvariants"])
133
+
134
+ if self.config.schema == "source":
135
+ for key, example in df.iterrows():
136
+ yield key, {
137
+ "synset": example["synset"],
138
+ "tlemma": example["tlemma"],
139
+ "tvariants": example["tvariants"],
140
+ }