Commit
·
0cc9f42
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +190 -0
- dataset_infos.json +1 -0
- dummy/tlcv1.0/1.0.0/dummy_data.zip +3 -0
- dummy/tlcv2.0/2.0.0/dummy_data.zip +3 -0
- dummy/tnhcv1.0/1.0.0/dummy_data.zip +3 -0
- tlc.py +128 -0
.gitattributes
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
annotations_creators:
|
| 3 |
+
- expert-generated
|
| 4 |
+
- no-annotation
|
| 5 |
+
language_creators:
|
| 6 |
+
- expert-generated
|
| 7 |
+
languages:
|
| 8 |
+
- th
|
| 9 |
+
licenses:
|
| 10 |
+
- unknown
|
| 11 |
+
multilinguality:
|
| 12 |
+
- monolingual
|
| 13 |
+
size_categories:
|
| 14 |
+
- n<1K
|
| 15 |
+
source_datasets:
|
| 16 |
+
- original
|
| 17 |
+
task_categories:
|
| 18 |
+
- sequence-modeling
|
| 19 |
+
task_ids:
|
| 20 |
+
- language-modeling
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
# Dataset Card for Thai Literature Corpora (TLC)
|
| 24 |
+
|
| 25 |
+
## Table of Contents
|
| 26 |
+
- [Dataset Description](#dataset-description)
|
| 27 |
+
- [Dataset Summary](#dataset-summary)
|
| 28 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
| 29 |
+
- [Languages](#languages)
|
| 30 |
+
- [Dataset Structure](#dataset-structure)
|
| 31 |
+
- [Data Instances](#data-instances)
|
| 32 |
+
- [Data Fields](#data-instances)
|
| 33 |
+
- [Data Splits](#data-instances)
|
| 34 |
+
- [Dataset Creation](#dataset-creation)
|
| 35 |
+
- [Curation Rationale](#curation-rationale)
|
| 36 |
+
- [Source Data](#source-data)
|
| 37 |
+
- [Annotations](#annotations)
|
| 38 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
| 39 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
| 40 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
| 41 |
+
- [Discussion of Biases](#discussion-of-biases)
|
| 42 |
+
- [Other Known Limitations](#other-known-limitations)
|
| 43 |
+
- [Additional Information](#additional-information)
|
| 44 |
+
- [Dataset Curators](#dataset-curators)
|
| 45 |
+
- [Licensing Information](#licensing-information)
|
| 46 |
+
- [Citation Information](#citation-information)
|
| 47 |
+
|
| 48 |
+
## Dataset Description
|
| 49 |
+
|
| 50 |
+
- **Homepage:** https://attapol.github.io/tlc.html
|
| 51 |
+
- **Leaderboard:** https://www.kaggle.com/c/wisesight-sentiment/
|
| 52 |
+
- **Paper:**
|
| 53 |
+
- **Leaderboard:**
|
| 54 |
+
- **Point of Contact:** Jitkapat Sawatphol, Attapol Rutherford; attapolrutherford at gmail.com
|
| 55 |
+
|
| 56 |
+
### Dataset Summary
|
| 57 |
+
Thai Literature Corpora (TLC): Corpora of machine-ingestible Thai classical literature texts.
|
| 58 |
+
|
| 59 |
+
It consists of two datasets:
|
| 60 |
+
|
| 61 |
+
## TLC set
|
| 62 |
+
It is texts from [Vajirayana Digital Library](https://vajirayana.org/), stored by chapters and stanzas (non-tokenized).
|
| 63 |
+
|
| 64 |
+
tlc v.2.0 (6/17/19 : a total of 34 documents, 292,270 lines, 31,790,734 characters)
|
| 65 |
+
tlc v.1.0 (6/11/19 : a total of 25 documents, 113,981 lines, 28,775,761 characters)
|
| 66 |
+
|
| 67 |
+
## TNHC set
|
| 68 |
+
It is texts from Thai National Historical Corpus, stored by lines (manually tokenized).
|
| 69 |
+
|
| 70 |
+
tnhc v.1.0 (6/25/19 : a total of 47 documents, 756,478 lines, 13,361,142 characters)
|
| 71 |
+
|
| 72 |
+
### Supported Tasks and Leaderboards
|
| 73 |
+
|
| 74 |
+
Language Modeling, Language Generation
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
### Languages
|
| 78 |
+
|
| 79 |
+
Thai
|
| 80 |
+
|
| 81 |
+
## Dataset Structure
|
| 82 |
+
|
| 83 |
+
### Data Instances
|
| 84 |
+
|
| 85 |
+
```
|
| 86 |
+
{
|
| 87 |
+
"ch_num": "๑",
|
| 88 |
+
"title": "กากี กลอนสุภาพ",
|
| 89 |
+
"text": [
|
| 90 |
+
[
|
| 91 |
+
"๏ จักกล่าวอดีตนิทานแต่ปางก่อน\n",
|
| 92 |
+
"เมื่อครั้งองค์สมเด็จพระชินวร\tยังสัญจรแสวงหาโพธิญาณ\n",
|
| 93 |
+
"เสวยชาติเป็นสกุณาพระยานก\tจึงชักเรื่องชาดกมาบรรหาร\n",
|
| 94 |
+
"หวังแสดงแห่งจิตหญิงพาล\tให้ชายชาญรู้เชิงกระสัตรี ฯ\n"
|
| 95 |
+
]
|
| 96 |
+
}
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
### Data Fields
|
| 100 |
+
|
| 101 |
+
- `ch_num`: chapter number in Thai Numerals (๑, ๒, ๓, ๔, ๕, ๖, ๗, ๘, ๙, ๑๐, ...)
|
| 102 |
+
- `title`: chapter name
|
| 103 |
+
- `text`: each item corresponds to one stanzas, each line is a couplet which can be seperated by `\t`
|
| 104 |
+
|
| 105 |
+
### Data Splits
|
| 106 |
+
|
| 107 |
+
tlc v.2.0 (6/17/19 : a total of 34 documents, 292,270 lines, 31,790,734 characters)
|
| 108 |
+
tlc v.1.0 (6/11/19 : a total of 25 documents, 113,981 lines, 28,775,761 characters)
|
| 109 |
+
|
| 110 |
+
## TNHC set
|
| 111 |
+
It is texts from Thai National Historical Corpus, stored by lines (manually tokenized).
|
| 112 |
+
|
| 113 |
+
tnhc v.1.0 (6/25/19 : a total of 47 documents, 756,478 lines, 13,361,142 characters)
|
| 114 |
+
|
| 115 |
+
| | tlc2.0 | tlc1.0 | tnhc |
|
| 116 |
+
|-----------|-------|-------|-------|
|
| 117 |
+
| # documents | 34 | 25 | 47 |
|
| 118 |
+
| # lines | 292,270 | 113,981 | 756,478 |
|
| 119 |
+
|
| 120 |
+
## Dataset Creation
|
| 121 |
+
|
| 122 |
+
### Curation Rationale
|
| 123 |
+
|
| 124 |
+
Originally, the dataset was compiled for the [Thai Poetry Generator](https://github.com/jitkapat/thaipoetrygenerator) at Chulalongkorn university as the Final project for `2209372 Introduction to Computational Linguistics` by [Jitkapat Sawatphol](https://jitkapat.github.io/) (Faculty of Engineering, Chulalongkorn University).
|
| 125 |
+
|
| 126 |
+
### Source Data
|
| 127 |
+
|
| 128 |
+
#### Initial Data Collection and Normalization
|
| 129 |
+
|
| 130 |
+
[More Information Needed]
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
#### Who are the source language producers?
|
| 134 |
+
|
| 135 |
+
[More Information Needed]
|
| 136 |
+
|
| 137 |
+
### Annotations
|
| 138 |
+
|
| 139 |
+
#### Annotation process
|
| 140 |
+
|
| 141 |
+
[More Information Needed]
|
| 142 |
+
|
| 143 |
+
#### Who are the annotators?
|
| 144 |
+
|
| 145 |
+
[More Information Needed]
|
| 146 |
+
|
| 147 |
+
### Personal and Sensitive Information
|
| 148 |
+
|
| 149 |
+
There is no personal information.
|
| 150 |
+
|
| 151 |
+
## Considerations for Using the Data
|
| 152 |
+
|
| 153 |
+
### Social Impact of Dataset
|
| 154 |
+
|
| 155 |
+
[More Information Needed]
|
| 156 |
+
|
| 157 |
+
### Discussion of Biases
|
| 158 |
+
|
| 159 |
+
[More Information Needed]
|
| 160 |
+
|
| 161 |
+
### Other Known Limitations
|
| 162 |
+
|
| 163 |
+
[More Information Needed]
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
## Additional Information
|
| 167 |
+
|
| 168 |
+
### Dataset Curators
|
| 169 |
+
|
| 170 |
+
Thanks [Jitkapat Sawatphol](https://jitkapat.github.io/) (Faculty of Arts, Chulalongkorn University), and [Attapol Rutherford](https://attapol.github.io/) (Faculty of Arts, Chulalongkorn University)
|
| 171 |
+
|
| 172 |
+
### Licensing Information
|
| 173 |
+
|
| 174 |
+
[More Information Needed]
|
| 175 |
+
|
| 176 |
+
### Citation Information
|
| 177 |
+
|
| 178 |
+
Please cite the following if you make use of the dataset:
|
| 179 |
+
|
| 180 |
+
Jitkapat Sawatphol, and Attapol Rutherford. 2019. **Thai Literature Corpora (TLC)**.
|
| 181 |
+
|
| 182 |
+
BibTeX:
|
| 183 |
+
```
|
| 184 |
+
@misc{
|
| 185 |
+
author={Sawatphol, Jitkapat},
|
| 186 |
+
title={Thai Literature Corpora},
|
| 187 |
+
year={2019},
|
| 188 |
+
howpublished={\\url{https://attapol.github.io/tlc.html}}
|
| 189 |
+
}
|
| 190 |
+
```
|
dataset_infos.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"tlcv2.0": {"description": "Thai Literature Corpora (TLC): Corpora of machine-ingestible Thai classical literature texts.\n\nRelease: 6/25/19\n\nIt consists of two datasets:\n\n## TLC set\nIt is texts from [Vajirayana Digital Library](https://vajirayana.org/), stored by chapters and stanzas (non-tokenized).\n\ntlc v.2.0 (6/17/19 : a total of 34 documents, 292,270 lines, 31,790,734 characters)\ntlc v.1.0 (6/11/19 : a total of 25 documents, 113,981 lines, 28,775,761 characters)\n\n## TNHC set\nIt is texts from Thai National Historical Corpus, stored by lines (manually tokenized).\n\ntnhc v.1.0 (6/25/19 : a total of 47 documents, 756,478 lines, 13,361,142 characters)\n", "citation": "@misc{\n author={Sawatphol, Jitkapat},\n title={Thai Literature Corpora},\n year={2019},\n howpublished={\\url{https://attapol.github.io/tlc.html}}\n}\n", "homepage": "https://attapol.github.io/tlc.html", "license": "", "features": {"ch_num": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "tlc", "config_name": "tlcv2.0", "version": {"version_str": "2.0.0", "description": null, "major": 2, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 32498, "num_examples": 1, "dataset_name": "tlc"}}, "download_checksums": {"https://drive.google.com/uc?export=download&id=1S2T72b3Kkcvy4XZcxwIipoRn6ELa4hhV": {"num_bytes": 5551710, "checksum": "56aff251d17a33b4c6a12d2b41c9fe6aaa676d08a87d12e253f465107b13ae88"}}, "download_size": 5551710, "post_processing_size": null, "dataset_size": 32498, "size_in_bytes": 5584208}, "tlcv1.0": {"description": "Thai Literature Corpora (TLC): Corpora of machine-ingestible Thai classical literature texts.\n\nRelease: 6/25/19\n\nIt consists of two datasets:\n\n## TLC set\nIt is texts from [Vajirayana Digital Library](https://vajirayana.org/), stored by chapters and stanzas (non-tokenized).\n\ntlc v.2.0 (6/17/19 : a total of 34 documents, 292,270 lines, 31,790,734 characters)\ntlc v.1.0 (6/11/19 : a total of 25 documents, 113,981 lines, 28,775,761 characters)\n\n## TNHC set\nIt is texts from Thai National Historical Corpus, stored by lines (manually tokenized).\n\ntnhc v.1.0 (6/25/19 : a total of 47 documents, 756,478 lines, 13,361,142 characters)\n", "citation": "@misc{\n author={Sawatphol, Jitkapat},\n title={Thai Literature Corpora},\n year={2019},\n howpublished={\\url{https://attapol.github.io/tlc.html}}\n}\n", "homepage": "https://attapol.github.io/tlc.html", "license": "", "features": {"ch_num": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "tlc", "config_name": "tlcv1.0", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 32498, "num_examples": 1, "dataset_name": "tlc"}}, "download_checksums": {"https://drive.google.com/uc?export=download&id=15E64fwMeAff0bAsFGaSsv9NYeVHn1drE": {"num_bytes": 2904472, "checksum": "9b27c79bfde97960f4cb3530a2e6a89360c219c0530e8aea593883f4847214df"}}, "download_size": 2904472, "post_processing_size": null, "dataset_size": 32498, "size_in_bytes": 2936970}, "tnhcv1.0": {"description": "Thai Literature Corpora (TLC): Corpora of machine-ingestible Thai classical literature texts.\n\nRelease: 6/25/19\n\nIt consists of two datasets:\n\n## TLC set\nIt is texts from [Vajirayana Digital Library](https://vajirayana.org/), stored by chapters and stanzas (non-tokenized).\n\ntlc v.2.0 (6/17/19 : a total of 34 documents, 292,270 lines, 31,790,734 characters)\ntlc v.1.0 (6/11/19 : a total of 25 documents, 113,981 lines, 28,775,761 characters)\n\n## TNHC set\nIt is texts from Thai National Historical Corpus, stored by lines (manually tokenized).\n\ntnhc v.1.0 (6/25/19 : a total of 47 documents, 756,478 lines, 13,361,142 characters)\n", "citation": "@misc{\n author={Sawatphol, Jitkapat},\n title={Thai Literature Corpora},\n year={2019},\n howpublished={\\url{https://attapol.github.io/tlc.html}}\n}\n", "homepage": "https://attapol.github.io/tlc.html", "license": "", "features": {"text": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "tlc", "config_name": "tnhcv1.0", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 25198, "num_examples": 152, "dataset_name": "tlc"}}, "download_checksums": {"https://drive.google.com/uc?export=download&id=1T_ib-NOwQV6O6lEjCjvZReUA3pQ4h-gD": {"num_bytes": 1465403, "checksum": "ba534fb18bb07595a82e3981a164384494b01d49918939b11fe417423a637e6f"}}, "download_size": 1465403, "post_processing_size": null, "dataset_size": 25198, "size_in_bytes": 1490601}}
|
dummy/tlcv1.0/1.0.0/dummy_data.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3f564dc06a1a491f5bf88bea6456d2f903cd401ab9c1e0eb479877b9f0303418
|
| 3 |
+
size 8970
|
dummy/tlcv2.0/2.0.0/dummy_data.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d38656e42759dd9c9bb62f982958ed1d853b2719299f9abafe07957b4a940f2b
|
| 3 |
+
size 8193
|
dummy/tnhcv1.0/1.0.0/dummy_data.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:58eb477558f5cbb608052add561dbc58aaf6fb5b8a0c4173206fd8d2b3950716
|
| 3 |
+
size 1503
|
tlc.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# -*- coding: utf-8 -*-
|
| 3 |
+
"""Thai Literature Corpora (TLC): Corpora of machine-ingestible Thai classical literature texts."""
|
| 4 |
+
|
| 5 |
+
from __future__ import absolute_import, division, print_function
|
| 6 |
+
|
| 7 |
+
import json
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
import datasets
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
_CITATION = """\
|
| 14 |
+
@misc{
|
| 15 |
+
author={Sawatphol, Jitkapat},
|
| 16 |
+
title={Thai Literature Corpora},
|
| 17 |
+
year={2019},
|
| 18 |
+
howpublished={\\url{https://attapol.github.io/tlc.html}}
|
| 19 |
+
}
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
_HOMEPAGE = "https://attapol.github.io/tlc.html"
|
| 23 |
+
|
| 24 |
+
_DESCRIPTION = """\
|
| 25 |
+
Thai Literature Corpora (TLC): Corpora of machine-ingestible Thai classical literature texts.
|
| 26 |
+
|
| 27 |
+
Release: 6/25/19
|
| 28 |
+
|
| 29 |
+
It consists of two datasets:
|
| 30 |
+
|
| 31 |
+
## TLC set
|
| 32 |
+
It is texts from [Vajirayana Digital Library](https://vajirayana.org/), stored by chapters and stanzas (non-tokenized).
|
| 33 |
+
|
| 34 |
+
tlc v.2.0 (6/17/19 : a total of 34 documents, 292,270 lines, 31,790,734 characters)
|
| 35 |
+
tlc v.1.0 (6/11/19 : a total of 25 documents, 113,981 lines, 28,775,761 characters)
|
| 36 |
+
|
| 37 |
+
## TNHC set
|
| 38 |
+
It is texts from Thai National Historical Corpus, stored by lines (manually tokenized).
|
| 39 |
+
|
| 40 |
+
tnhc v.1.0 (6/25/19 : a total of 47 documents, 756,478 lines, 13,361,142 characters)
|
| 41 |
+
"""
|
| 42 |
+
|
| 43 |
+
_URLs = {
|
| 44 |
+
"tlcv1.0": "https://drive.google.com/uc?export=download&id=15E64fwMeAff0bAsFGaSsv9NYeVHn1drE",
|
| 45 |
+
"tlcv2.0": "https://drive.google.com/uc?export=download&id=1S2T72b3Kkcvy4XZcxwIipoRn6ELa4hhV",
|
| 46 |
+
"tnhcv1.0": "https://drive.google.com/uc?export=download&id=1T_ib-NOwQV6O6lEjCjvZReUA3pQ4h-gD",
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class TlcConfig(datasets.BuilderConfig):
|
| 51 |
+
"""BuilderConfig for Tlc."""
|
| 52 |
+
|
| 53 |
+
def __init__(self, **kwargs):
|
| 54 |
+
"""BuilderConfig for Tlc.
|
| 55 |
+
|
| 56 |
+
Args:
|
| 57 |
+
**kwargs: keyword arguments forwarded to super.
|
| 58 |
+
"""
|
| 59 |
+
super(TlcConfig, self).__init__(**kwargs)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
class Tlc(datasets.GeneratorBasedBuilder):
|
| 63 |
+
"""Thai Literature Corpora (TLC): Corpora of machine-ingestible Thai classical literature texts."""
|
| 64 |
+
|
| 65 |
+
BUILDER_CONFIGS = [
|
| 66 |
+
datasets.BuilderConfig(
|
| 67 |
+
name="tlcv1.0", version=datasets.Version("1.0.0"), description="Thai Literature Corpora"
|
| 68 |
+
),
|
| 69 |
+
datasets.BuilderConfig(
|
| 70 |
+
name="tlcv2.0", version=datasets.Version("2.0.0"), description="Thai Literature Corpora"
|
| 71 |
+
),
|
| 72 |
+
datasets.BuilderConfig(
|
| 73 |
+
name="tnhcv1.0",
|
| 74 |
+
version=datasets.Version("1.0.0"),
|
| 75 |
+
description="Thai Literature Corpora: Thai National Historical Corpus",
|
| 76 |
+
),
|
| 77 |
+
]
|
| 78 |
+
|
| 79 |
+
DEFAULT_CONFIG_NAME = "tlcv2.0"
|
| 80 |
+
|
| 81 |
+
def _info(self):
|
| 82 |
+
if self.config.name.startswith("tlc"):
|
| 83 |
+
features = datasets.Features(
|
| 84 |
+
{
|
| 85 |
+
"ch_num": datasets.Value("string"),
|
| 86 |
+
"title": datasets.Value("string"),
|
| 87 |
+
"text": datasets.Sequence(datasets.Sequence(datasets.Value("string"))),
|
| 88 |
+
}
|
| 89 |
+
)
|
| 90 |
+
else:
|
| 91 |
+
features = datasets.Features(
|
| 92 |
+
{
|
| 93 |
+
"text": datasets.Sequence((datasets.Value("string"))),
|
| 94 |
+
}
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
return datasets.DatasetInfo(
|
| 98 |
+
description=_DESCRIPTION,
|
| 99 |
+
features=features,
|
| 100 |
+
supervised_keys=None,
|
| 101 |
+
homepage=_HOMEPAGE,
|
| 102 |
+
citation=_CITATION,
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
def _split_generators(self, dl_manager):
|
| 106 |
+
data_path = dl_manager.download_and_extract(_URLs[self.config.name])
|
| 107 |
+
return [
|
| 108 |
+
datasets.SplitGenerator(
|
| 109 |
+
name=datasets.Split.TRAIN,
|
| 110 |
+
gen_kwargs={"directory": data_path},
|
| 111 |
+
)
|
| 112 |
+
]
|
| 113 |
+
|
| 114 |
+
def _generate_examples(self, directory):
|
| 115 |
+
if self.config.name.startswith("tlc"):
|
| 116 |
+
files = [os.path.join(directory, "นิราศอิเหนา.json")]
|
| 117 |
+
else:
|
| 118 |
+
files = [os.path.join(directory, "กาพย์เห่เรือ.json")]
|
| 119 |
+
|
| 120 |
+
_id = 0
|
| 121 |
+
for txt_file in files:
|
| 122 |
+
data = json.load(open(txt_file, encoding="utf-8"))
|
| 123 |
+
for d in data:
|
| 124 |
+
if self.config.name.startswith("tlc"):
|
| 125 |
+
yield _id, d
|
| 126 |
+
else:
|
| 127 |
+
yield _id, {"text": d}
|
| 128 |
+
_id += 1
|