CodeIsAbstract commited on
Commit
6246d18
·
verified ·
1 Parent(s): 8baaefd

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +399 -0
README.md ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - sa
4
+ - en
5
+ license:
6
+ - cc-by-4.0
7
+ - cc-by-sa-4.0
8
+ multilinguality:
9
+ - monolingual
10
+ size_categories:
11
+ - 100K<n<1M
12
+ task_categories:
13
+ - token-classification
14
+ - structured-prediction
15
+ - sequence-modeling
16
+ task_ids:
17
+ - part-of-speech-tagging
18
+ - lemmatization
19
+ - morphological-analysis
20
+ pretty_name: Sanskrit Morphological Sequence Corpus (Vidyut-Verified)
21
+ tags:
22
+ - sanskrit
23
+ - morphology
24
+ - vyakarana
25
+ - pāṇinian
26
+ - vidyut
27
+ - dcs
28
+ - universal-dependencies
29
+ - slp1
30
+ configs:
31
+ - config_name: default
32
+ data_files:
33
+ - split: train
34
+ path: data-train-0.parquet
35
+ ---
36
+
37
+ # Sanskrit Morphological Sequence Corpus (Vidyut-Verified)
38
+
39
+ A large-scale, **Pāṇinian-verified** morphological sequence dataset for
40
+ classical and Vedic Sanskrit. Every token is annotated with its lemma,
41
+ generative root (aupadeśika), part-of-speech, case, number, person, voice,
42
+ and gender — all in the SLP1 transliteration, and all aligned at the
43
+ sentence level for sequence-tagging / seq2seq training.
44
+
45
+ - **710,785 sentences** (after deduplication)
46
+ - **5,511,664 tokens**
47
+ - **14 columns** (10 linguistic + 4 Vidyut verification annotations)
48
+ - **Parquet format** (columnar, compressed)
49
+ - **Sources**: Digital Corpus of Sanskrit (DCS, CC BY 4.0) + Universal
50
+ Dependencies Sanskrit treebanks (UD-Sanskrit-Vedic, UD-Sanskrit-UFAL;
51
+ CC BY-SA 4.0)
52
+
53
+ ---
54
+
55
+ ## Dataset Summary
56
+
57
+ | | |
58
+ |---|---|
59
+ | Sentences | 710,785 |
60
+ | Tokens | 5,511,664 |
61
+ | Vocabulary (types) | ~30k lemmas |
62
+ | Transliteration | SLP1 (Sanskrit Library Phonetic Basic) |
63
+ | Schema per row | sentence-aligned sequences of token-level annotations |
64
+ | Verification | Vidyut 0.4.0 Pāṇinian round-trip checksum on every token |
65
+ | Format | Apache Parquet |
66
+ | License | CC BY 4.0 (DCS) / CC BY-SA 4.0 (UD) — see *Licensing* below |
67
+
68
+ ### Token-level POS distribution
69
+
70
+ | Vidyut POS | Tokens | % | Meaning |
71
+ |---|---:|---:|---|
72
+ | `Subanta` | 3,542,853 | 64.3% | Declined nominals (nouns, pronouns, adjectives, numerals) |
73
+ | `Avyaya` | 1,002,920 | 18.2% | Indeclinables (adverbs, particles, conjunctions) |
74
+ | `Tinanta` | 520,321 | 9.4% | Finite verbs |
75
+ | `Krdanta` | 445,570 | 8.1% | Non-finite verb forms (participles, infinitives, gerunds, absolutives) |
76
+
77
+ ---
78
+
79
+ ## Schema (14 columns)
80
+
81
+ Each row is one sentence. All `Sequence` columns are equal-length, aligned
82
+ token-by-token.
83
+
84
+ ### Linguistic columns (10)
85
+
86
+ | Column | Type | Description |
87
+ |---|---|---|
88
+ | `id` | `string` | Source sentence id (DCS occurrence id or UD `sent_id`) |
89
+ | `tokens` | `Sequence[string]` | SLP1 surface words (sandhi-split padāni) |
90
+ | `lemmas` | `Sequence[string]` | SLP1 clean lexical lemma (dictionary form) |
91
+ | `aupadeshika` | `Sequence[string]` | SLP1 generative root blueprint (accented, with prefixes/sanādi); for `Subanta`/`Avyaya` equals the lemma; for `Tinanta`/`Krdanta` resolved via the Vidyut Kosha (e.g. `kf` → `kf\Y`) |
92
+ | `pos_tags` | `Sequence[string]` | Vidyut POS: `Subanta` / `Tinanta` / `Krdanta` / `Avyaya` |
93
+ | `vibhakti` | `Sequence[string]` | Vidyut case (8 values) or `"None"` if inapplicable |
94
+ | `vacana` | `Sequence[string]` | Vidyut number: `eka` / `dvi` / `bahu`, or `"None"` |
95
+ | `purusha` | `Sequence[string]` | Vidyut person: `praTama` / `maDyama` / `uttama`, or `"None"` |
96
+ | `prayoga` | `Sequence[string]` | Vidyut voice: `kartari` / `karmaRi` / `BAve`, or `"None"` |
97
+ | `linga` | `Sequence[string]` | Vidyut gender: `puM` / `strI` / `napuMsaka`, or `"None"` |
98
+
99
+ ### Verification columns (4)
100
+
101
+ | Column | Type | Description |
102
+ |---|---|---|
103
+ | `n_match` | `int64` | # tokens Vidyut generated and matched the surface form |
104
+ | `n_mismatch` | `int64` | # tokens Vidyut generated but did NOT match (likely ārṣa/Vedic irregularity or rare mapping edge-case) |
105
+ | `n_unverified` | `int64` | # tokens Vidyut could not attempt (engine coverage gap: pronoun sarvanāmasa, special `-ī` stems, some kṛt pratyayas) |
106
+ | `verification` | `string` | Categorical status (see *Verification status* below) |
107
+
108
+ ### Null-padding convention
109
+
110
+ Features that don't apply to a given POS class are the literal string
111
+ `"None"` (not the Python `None`):
112
+
113
+ | POS class | `vibhakti` | `vacana` | `purusha` | `prayoga` | `linga` |
114
+ |---|---|---|---|---|---|
115
+ | `Subanta` (nominal) | ✓ | ✓ | None | None | ✓ |
116
+ | `Tinanta` (finite verb) | None | ✓ | ✓ | ✓ | None |
117
+ | `Krdanta` (participle) | ✓ | ✓ | None | ✓ | ✓ |
118
+ | `Avyaya` (indeclinable) | None | None | None | None | None |
119
+
120
+ ### Vidyut enum value strings
121
+
122
+ The `vibhakti` / `vacana` / `purusha` / `prayoga` / `linga` columns use the
123
+ exact SLP1 strings Vidyut's `from_string` classmethods accept, so the
124
+ columns can be fed directly into `vidyut.prakriya.{Vibhakti,Vacana,Purusha,
125
+ Prayoga,Linga}.from_string(value)`:
126
+
127
+ - **vibhakti**: `praTamA`, `dvitIyA`, `tftIyA`, `caturTI`, `paYcamI`, `zazWI`, `saptamI`, `samboDanam`
128
+ - **vacana**: `eka`, `dvi`, `bahu`
129
+ - **purusha**: `praTama`, `maDyama`, `uttama`
130
+ - **prayoga**: `kartari`, `karmaRi`, `BAve`
131
+ - **linga**: `puM`, `strI`, `napuMsaka`
132
+
133
+ ---
134
+
135
+ ## Sources
136
+
137
+ ### 1. Digital Corpus of Sanskrit (DCS) — primary
138
+
139
+ - URL: https://github.com/OliverHellwig/sanskrit
140
+ - Path in repo: `dcs/data/conllu/`
141
+ - Format: UD-compatible CoNLL-U, **IAST** transliteration
142
+ - Size: ~745k sentences / ~5.5M tokens, ~15,900 `.conllu` files
143
+ - Coverage: Ṛgveda, Atharvaveda (Śaunaka & Paippalāda), Mahābhārata, Rāmāyaṇa, major Upaniṣads, sūtras, Purāṇas, Buddhist Sanskrit, grammatical treatises, and more.
144
+ - License: **CC BY 4.0**
145
+ - Citation: *Oliver Hellwig, Digital Corpus of Sanskrit (DCS), 2010–2024.*
146
+
147
+ DCS is not web-scraped text. It is the product of over a decade of
148
+ computational-linguistic work by Dr. Oliver Hellwig and collaborators,
149
+ run through constraint-solvers and hand-corrected by Sanskrit experts.
150
+ It is currently the most rigorously peer-reviewed Sanskrit morphological
151
+ database in existence.
152
+
153
+ ### 2. Universal Dependencies — Sanskrit treebanks
154
+
155
+ - **UD_Sanskrit-Vedic**: https://github.com/UniversalDependencies/UD_Sanskrit-Vedic
156
+ - **UD_Sanskrit-UFAL**: https://github.com/UniversalDependencies/UD_Sanskrit-UFAL
157
+ - Format: CoNLL-U, **IAST** transliteration
158
+ - License: **CC BY-SA 4.0**
159
+
160
+ UD rows are identifiable by a `_` in their `id` (e.g. `71508_1`); DCS rows
161
+ by a numeric occurrence id (e.g. `96540`).
162
+
163
+ ---
164
+
165
+ ## Construction Pipeline
166
+
167
+ The dataset was built by the `sanskrit_morpho` package:
168
+
169
+ 1. **Fetch** — shallow-clone UD treebanks; sparse-checkout only
170
+ `dcs/data/conllu/` from the DCS repo (no C++/R analysis code).
171
+ 2. **Parse** — standard CoNLL-U parser; multi-word sandhi-fused range
172
+ rows (e.g. `1-2 bhagavāñśrāvastyāṃ`) are dropped when the split
173
+ padāni follow; purely fused blocks with no split forms are dropped.
174
+ 3. **Normalize to SLP1** — all tokens and lemmas transliterated from IAST
175
+ to SLP1. The terminal-anusvāra rule is applied per token: a trailing
176
+ `M` (anusvāra) at word-end is normalized to the labial nasal `m`
177
+ (e.g. `vanaM` → `vanam`); medial anusvāras are preserved (sandhi-relevant).
178
+ 4. **Tag-map to Vidyut** — UD `UPOS` → Vidyut `Subanta/Tinanta/Avyaya/Krdanta`;
179
+ UD `Case/Number/Person/Voice/Gender` → Vidyut
180
+ `vibhakti/vacana/purusha/prayoga/linga`. Non-finite `VerbForm`
181
+ (`Part`, `Inf`, `Ger`, `Conv`, `Abs`) overrides `Tinanta` → `Krdanta`.
182
+ 5. **Null-pad** — inapplicable features set to the string `"None"`.
183
+ 6. **Aupadeśika resolution** — for `Tinanta`/`Krdanta`, the clean SLP1
184
+ lemma is looked up in the Vidyut Kosha (45k-entry dhatu index) and the
185
+ metalanguage `aupadeshika` root (accented, with prefixes/sanādi) is
186
+ stored in the `aupadeshika` column.
187
+ 7. **QC drop (build-time)** — drop incomplete sentences (any token with
188
+ missing POS or lemma) and purely-sandhi-fused blocks with no split
189
+ forms. 1 row dropped at build time.
190
+ 8. **Dedup + verify (post-build)** — exact-sentence deduplication +
191
+ structural validation + Vidyut round-trip verification.
192
+
193
+ ---
194
+
195
+ ## Verification (Vidyut Round-Trip Checksum)
196
+
197
+ Every token was verified using [Vidyut 0.4.0](https://github.com/ambuda-org/vidyut)
198
+ (Ambuda's Pāṇinian engine) as a cryptographic checksum. The direction is
199
+ **backward** (the only direction Vidyut supports — it can generate but
200
+ cannot decompose):
201
+
202
+ 1. **Read row**: pull a token's `aupadeshika` / `lemmas` + `pos_tags` +
203
+ `vibhakti` / `vacana` / `purusha` / `prayoga` / `linga`.
204
+ 2. **Generate**: construct a `vidyut.prakriya.Pada` and call
205
+ `Vyakarana().derive()` to produce all Pāṇinian surface forms.
206
+ 3. **Assert**: check if Vidyut's generated output contains the surface
207
+ token from the dataset.
208
+
209
+ A per-token verdict of `match` / `mismatch` / `unverified` is recorded,
210
+ then aggregated per sentence into the `verification` column. Missing
211
+ features iterate over all possible enum values so partially-annotated
212
+ tokens (e.g. pronouns without gender) can still match.
213
+
214
+ ### Verification status distribution
215
+
216
+ | `verification` | Sentences | % | Meaning |
217
+ |---|---:|---:|---|
218
+ | `full_match` | 35,500 | 5.0% | Every token Pāṇini-compliant — **verified strict gold** |
219
+ | `partial_match` | 124,056 | 17.5% | All verifiable tokens matched; some `unverified` (Vidyut coverage gaps only, zero mismatches) |
220
+ | `has_mismatch` | 546,229 | 76.8% | ≥1 token Vidyut could not match (ārṣa / Vedic irregularities, pronoun sarvanāmasa, special `-ī` stems) |
221
+ | `all_unverified` | 5,000 | 0.7% | No token could be verified (full Vidyut coverage gap) |
222
+
223
+ **The `has_mismatch` rows are NOT bad data.** They are correct DCS/UD
224
+ gold annotations that Vidyut's classical-Pāṇinian engine cannot generate
225
+ (e.g. Vedic `ārṣa prayoga` that violates strict classical rules, or
226
+ pronoun paradigms outside the `Pratipadika.basic()` generation path).
227
+ They are retained so the corpus is lossless; consumers can filter them
228
+ out for a strict-classical subset.
229
+
230
+ ### Recommended subsets
231
+
232
+ - **Vidyut-Verified Strict Gold**: `verification == "full_match"` → 35,500 sentences
233
+ - **No-mismatch gold** (includes engine-coverage gaps): `verification in {"full_match", "partial_match"}` → 159,556 sentences
234
+ - **Full corpus** (includes Vedic irregularities): all 710,785 sentences
235
+
236
+ ---
237
+
238
+ ## Quickstart
239
+
240
+ ### Load with Hugging Face `datasets`
241
+
242
+ ```python
243
+ from datasets import load_dataset
244
+ ds = load_dataset("parquet", data_files="./data-train-0.parquet")["train"]
245
+ print(ds[0])
246
+ ```
247
+
248
+ ### Load with pyarrow
249
+
250
+ ```python
251
+ import pyarrow.parquet as pq
252
+ t = pq.read_table("./data-train-0.parquet")
253
+ # strict gold subset
254
+ mask = [v == "full_match" for v in t.column("verification").to_pylist()]
255
+ strict = t.filter(mask)
256
+ ```
257
+
258
+ ### Example row (full_match)
259
+
260
+ ```json
261
+ {
262
+ "id": "71509_1",
263
+ "tokens": ["prayacCati"],
264
+ "lemmas": ["prayam"],
265
+ "aupadeshika": ["ya\\ma~"],
266
+ "pos_tags": ["Tinanta"],
267
+ "vibhakti": ["None"],
268
+ "vacana": ["eka"],
269
+ "purusha": ["praTama"],
270
+ "prayoga": ["None"],
271
+ "linga": ["None"],
272
+ "n_match": 1,
273
+ "n_mismatch": 0,
274
+ "n_unverified": 0,
275
+ "verification": "full_match"
276
+ }
277
+ ```
278
+
279
+ The surface token `prayacCati` ("he gives") is regenerated by Vidyut from
280
+ the root `ya\ma~` (= `pra` + `yam`) + `Tinanta` + `kartari` (default) +
281
+ `praTama` + `eka` + `Lat` (present) — confirming the annotation is
282
+ Pāṇini-compliant.
283
+
284
+ ---
285
+
286
+ ## Intended Uses
287
+
288
+ - **Morphological tagging (CRF / neural sequence models)**: input
289
+ `tokens`, predict `pos_tags` / `vibhakti` / `vacana` / `purusha` /
290
+ `prayoga` / `linga`. The `prayoga` (voice) column is especially
291
+ critical for learning passive-construction transition weights.
292
+ - **Lemmatization (seq2seq)**: input `tokens`, predict `lemmas`.
293
+ - **Generative verification**: input `aupadeshika` + morph features,
294
+ generate the surface form and compare — useful as a Pāṇinian
295
+ auto-grader or for data augmentation.
296
+ - **Transliterator normalization benchmark**: train/test SLP1 normalization
297
+ on real-world IAST input.
298
+
299
+ ### Out-of-scope
300
+
301
+ - Sandhi splitting (the dataset stores already-split padāni).
302
+ - Dependency parsing (UD `head`/`deprel` are not in the schema; DCS
303
+ doesn't annotate them).
304
+ - Semantics / WordNet senses (DCS ships `WordSem` ids in the raw CoNLL-U
305
+ `MISC` field but they are not surfaced here).
306
+
307
+ ---
308
+
309
+ ## Limitations
310
+
311
+ 1. **`has_mismatch` is 76.8%.** This is mathematically expected — the
312
+ corpus is dominated by DCS classical/Vedic text containing many
313
+ ārṣa prayoga and forms outside Vidyut's basic-substantive generation
314
+ path. It does NOT indicate annotation errors. Use the `verification`
315
+ column to select the subset appropriate for your task.
316
+ 2. **Tense/Mood not stored.** The verifier defaults verbs to the present
317
+ indicative (`Lat`) when `Tense`/`Mood` are absent from the schema.
318
+ Non-present verbs that Vidyut generates under `Lat` may therefore
319
+ appear as `has_mismatch` even when the annotation is correct. If you
320
+ need tense/lakara, re-parse the source CoNLL-U `FEATS` field.
321
+ 3. **`is_akarmaka` (transitivity) is not in the dataset.** It is
322
+ derivable at runtime from the `aupadeshika` via the Vidyut Kosha /
323
+ Dhatupatha lookup (the dhatu entry's `karmatva` field), per the
324
+ downstream CRF feature design.
325
+ 4. **Causative voice** (`kartRka`) is not a Vidyut `Prayoga` enum
326
+ (Vidyut 0.4.0 has only `kartari` / `karmaRi` / `BAve`); causative
327
+ verbs will show `prayoga="None"` or `unverified`.
328
+
329
+ ---
330
+
331
+ ## Licensing
332
+
333
+ This dataset is a transformation of three upstream sources:
334
+
335
+ - **DCS** (Oliver Hellwig): **CC BY 4.0**
336
+ - **UD_Sanskrit-Vedic**: **CC BY-SA 4.0**
337
+ - **UD_Sanskrit-UFAL**: **CC BY-SA 4.0**
338
+
339
+ The combined dataset is released under **CC BY-SA 4.0** (the most
340
+ restrictive of the upstream licenses). You must:
341
+
342
+ - Provide attribution (cite the sources below).
343
+ - Indicate any modifications.
344
+ - Distribute derivatives under a compatible license (Share-Alike).
345
+
346
+ ### Citation
347
+
348
+ ```bibtex
349
+ @misc{sanskrit_morpho_v1_verified,
350
+ title = {Sanskrit Morphological Sequence Corpus (Vidyut-Verified)},
351
+ year = {2026},
352
+ note = {Built from DCS and Universal Dependencies Sanskrit treebanks,
353
+ with Vidyut 0.4.0 Pāṇinian round-trip verification.},
354
+ }
355
+
356
+ @misc{hellwig_dcs,
357
+ author = {Hellwig, Oliver},
358
+ title = {Digital Corpus of Sanskrit (DCS)},
359
+ year = {2010--2024},
360
+ url = {https://github.com/OliverHellwig/sanskrit},
361
+ }
362
+
363
+ @misc{ud_sanskrit,
364
+ author = {Universal Dependencies},
365
+ title = {UD Sanskrit (Vedic + UFAL)},
366
+ url = {https://universaldependencies.org/sa/index.html},
367
+ }
368
+
369
+ @misc{vidyut,
370
+ author = {Ambuda},
371
+ title = {Vidyut: A Pāṇinian Sanskrit toolkit},
372
+ url = {https://github.com/ambuda-org/vidyut},
373
+ }
374
+ ```
375
+
376
+ ---
377
+
378
+ ## Reproducibility
379
+
380
+ The dataset is fully reproducible from sources with the `sanskrit_morpho`
381
+ package:
382
+
383
+ ```bash
384
+ # 1. Build (fetch + parse + SLP1 + tag-map + aupadeshika)
385
+ PYTHONPATH=src python -m sanskrit_morpho.build \
386
+ --raw-dir ./raw_morpho_data \
387
+ --out-dir ./sanskrit_morpho_v1 \
388
+ --sources ud_vedic,ud_ufal,dcs
389
+
390
+ # 2. Verify + dedup + write parquet
391
+ PYTHONPATH=src python -m sanskrit_morpho.verify \
392
+ --in-dir ./sanskrit_morpho_v1/full \
393
+ --out-dir ./sanskrit_morpho_v1_verified \
394
+ --kosha-dir ./vidyut-data/kosha \
395
+ --format parquet
396
+ ```
397
+
398
+ Vidyut's linguistic data pack is downloaded once via
399
+ `python -c "import vidyut; vidyut.download_data('./vidyut-data')"`.