Datasets:

Languages:
Burmese
ArXiv:
License:
holylovenia commited on
Commit
0c2122e
1 Parent(s): cf0cfe6

Upload burmese_romanize.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. burmese_romanize.py +123 -0
burmese_romanize.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 import schemas
8
+ from seacrowd.utils.configs import SEACrowdConfig
9
+ from seacrowd.utils.constants import Tasks, Licenses
10
+
11
+ _CITATION = """\
12
+ @inproceedings{chenchen2017statistical,
13
+ author = {Ding Chenchen and
14
+ Chea Vichet and
15
+ Pa Win Pa and
16
+ Utiyama Masao and
17
+ Sumita Eiichiro},
18
+ title = {Statistical Romanization for Abugida Scripts: Data and Experiment on Khmer and Burmese},
19
+ booktitle = {Proceedings of the 23rd Annual Conference of the Association for Natural Language Processing,
20
+ {NLP2017}, Tsukuba, Japan, 13-17 March 2017},
21
+ year = {2017},
22
+ url = {https://www.anlp.jp/proceedings/annual_meeting/2017/pdf_dir/P5-7.pdf},
23
+ }
24
+ """
25
+
26
+ _DATASETNAME = "burmese_romanize"
27
+ _DESCRIPTION = """\
28
+ This dataset consists of 2,335 Burmese names from real university students and faculty,
29
+ public figures, and minorities from Myanmar. Each entry includes the original name in
30
+ Burmese script, its corresponding Romanization, and the aligned Burmese and Latin
31
+ graphemes.
32
+ """
33
+
34
+ _HOMEPAGE = "http://www.nlpresearch-ucsy.edu.mm/NLP_UCSY/name-db.html"
35
+ _LANGUAGES = ["mya"]
36
+ _LICENSE = Licenses.CC_BY_NC_SA_4_0.value
37
+ _URLS = "http://www.nlpresearch-ucsy.edu.mm/NLP_UCSY/myanmaroma.zip"
38
+
39
+ _SUPPORTED_TASKS = [Tasks.TRANSLITERATION]
40
+ _SOURCE_VERSION = "1.0.0"
41
+ _SEACROWD_VERSION = "2024.06.20"
42
+
43
+ _LOCAL = False
44
+
45
+
46
+ class BurmeseRomanizeDataset(datasets.GeneratorBasedBuilder):
47
+ """Romanization of names in Burmese script"""
48
+
49
+ SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
50
+ SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
51
+
52
+ SEACROWD_SCHEMA_NAME = "t2t"
53
+
54
+ BUILDER_CONFIGS = [
55
+ SEACrowdConfig(
56
+ name=f"{_DATASETNAME}_source",
57
+ version=SOURCE_VERSION,
58
+ description=f"{_DATASETNAME} source schema",
59
+ schema="source",
60
+ subset_id=f"{_DATASETNAME}",
61
+ ),
62
+ SEACrowdConfig(
63
+ name=f"{_DATASETNAME}_seacrowd_{SEACROWD_SCHEMA_NAME}",
64
+ version=SEACROWD_VERSION,
65
+ description=f"{_DATASETNAME} SEACrowd schema",
66
+ schema=f"seacrowd_{SEACROWD_SCHEMA_NAME}",
67
+ subset_id=f"{_DATASETNAME}",
68
+ ),
69
+ ]
70
+
71
+ DEFAULT_CONFIG_NAME = f"{_DATASETNAME}_source"
72
+
73
+ def _info(self) -> datasets.DatasetInfo:
74
+ if self.config.schema == "source":
75
+ features = datasets.Features(
76
+ {
77
+ "original": datasets.Value("string"),
78
+ "romanized": datasets.Value("string"),
79
+ "aligned_graphemes": datasets.Sequence(datasets.Value("string")),
80
+ }
81
+ )
82
+ elif self.config.schema == f"seacrowd_{self.SEACROWD_SCHEMA_NAME}":
83
+ features = schemas.text2text_features
84
+
85
+ return datasets.DatasetInfo(
86
+ description=_DESCRIPTION,
87
+ features=features,
88
+ homepage=_HOMEPAGE,
89
+ license=_LICENSE,
90
+ citation=_CITATION,
91
+ )
92
+
93
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
94
+ data_dir = Path(dl_manager.download_and_extract(_URLS)) / "myanmaroma"
95
+
96
+ return [
97
+ datasets.SplitGenerator(
98
+ name=datasets.Split.TRAIN,
99
+ gen_kwargs={
100
+ "filepath": data_dir / "myanmaroma.txt",
101
+ "split": "train",
102
+ },
103
+ ),
104
+ ]
105
+
106
+ def _generate_examples(self, filepath: Path, split: str) -> Tuple[int, Dict]:
107
+ df = pd.read_csv(filepath, sep=" \|\|\| ", engine='python', header=None, names=["ori", "roman", "seg"])
108
+ if self.config.schema == "source":
109
+ for i, row in df.iterrows():
110
+ yield i, {
111
+ "original": row["ori"],
112
+ "romanized": row["roman"],
113
+ "aligned_graphemes": row["seg"].strip().split(),
114
+ }
115
+ elif self.config.schema == f"seacrowd_{self.SEACROWD_SCHEMA_NAME}":
116
+ for i, row in df.iterrows():
117
+ yield i, {
118
+ "id": str(i),
119
+ "text_1": row["ori"],
120
+ "text_2": row["roman"],
121
+ "text_1_name": "original",
122
+ "text_2_name": "romanized",
123
+ }