Skip to content

Commit

Permalink
[prakriya] Fix various correctness bugs
Browse files Browse the repository at this point in the history
- Support `Guzwa` and `Guzita` (#141)
- Fix spelling of dhatu 01.0379 (#142)
- Add support for `araDat` (#143)
- Mark `Gas` as anit (#144)
- Fix `kzam` + yaN-luk (#145)
- Fix forms of curAdi `sad` (#146)
- Update readme and fix Babylon example (#147)
- Support `caMcUryate etc. (#148)`
  • Loading branch information
akprasad committed Dec 29, 2024
1 parent 863c667 commit c0fa416
Show file tree
Hide file tree
Showing 25 changed files with 477 additions and 136 deletions.
26 changes: 13 additions & 13 deletions vidyut-prakriya/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,61 +31,61 @@ test_tinantas:
../target/release/test_results \
--data-type tinanta \
--test-cases test-files/tinantas-basic.csv \
--hash "b5af09ca0580ca14484f75618e7515b29c16054111092b5cc550accb244e1e28"
--hash "8ae177857fb0ba870a6269ec6d96a78ee7e3d6ae0586f69e072b29ccc9108562"
../target/release/test_results \
--data-type tinanta \
--test-cases test-files/tinantas-nic.csv \
--hash "d8cf36e3354075b014761ecb39180655f50498c032fd262e0f9f3d7e0558ab95"
--hash "1cc63c02a628e8ed843c455c90dd327f25c7c824fea32e8642851b0011e47666"
../target/release/test_results \
--data-type tinanta \
--test-cases test-files/tinantas-san.csv \
--hash "bb44e1642942c47e8d4fe09cefdab4f005c0b2653e4dc72f847b9cbf33ac9694"
--hash "69c5de2266c7a8911fbea09fbef85951c94da818f7994d560ce62de92dd18074"
../target/release/test_results \
--data-type tinanta \
--test-cases test-files/tinantas-yan.csv \
--hash "06b136ed48064c00eed2e6320ebdc8b086a0e93bd3dedbb375a3d680f23a14a0"
--hash "436443c42c36e075bb866088b92456a8fedbe8c5f63686cae72d9f04897402ef"
../target/release/test_results \
--data-type tinanta \
--test-cases test-files/tinantas-yan-luk.csv \
--hash "7cd36afdcd38beef9bd66db40e41a080e2db2aea794f6daa06e926096ae48104"
--hash "bf4fbfd3e775057628656ce3af7760a2f80b69e2a410086465d616330e7041a7"
../target/release/test_results \
--data-type tinanta \
--test-cases test-files/tinantas-san-nic.csv \
--hash "c1f561806c1639926621dcabf69a31285b99f00c80e5fa57e3a4a4afa9310499"
--hash "4b7a5b83786a3ef53dec0bbf580a224f5161bf2f3dc2f2e8a917ba231e25e225"
../target/release/test_results \
--data-type tinanta \
--test-cases test-files/tinantas-nic-san.csv \
--hash "8e102d104eea6483e82ad2be8a8005716586ce4b0d2aa447fc20ada0f2882158"
--hash "fb647997a7f2956a45deeb7400d8ed11359448a0edc43c16725ba597855db768"

test_krdantas:
cargo build --release --bin test_results
../target/release/test_results \
--data-type krdanta \
--test-cases test-files/krdantas-basic.csv \
--hash "4ff8687f9a2c36eddd58a23637983ec87319ed5c4616aabe686d0e2b91a558b2"
--hash "6160c100552db7946294e12054e57111e36e766d726dd0268b828eeb14056369"
../target/release/test_results \
--data-type krdanta \
--test-cases test-files/krdantas-nic.csv \
--hash "2acacdc4000bd02a58905ef431a65d9d3666296ef9ed9ab0571935f7586e12b9"
--hash "d7579416e7c2041f50c8502e3f48610e8f874625e39b215db782240829baf63e"
../target/release/test_results \
--data-type krdanta \
--test-cases test-files/krdantas-san.csv \
--hash "294ecfdf8ad81c0164c466b423a3f088f01c7de7894d5efb5fadb74294bf05ff"
--hash "66d71a1de6fc1803edb7e65ee1332e2432aa6f8f29ec9055a86c646307c7207f"
../target/release/test_results \
--data-type krdanta \
--test-cases test-files/krdantas-yan.csv \
--hash "51d9faea44e8295a8e942a0bab8d8f66d4412ff9767c70d24be4408648b7781f"
--hash "5512ddc37a4ead2d0f983875f3c705c0237d2d482a24dcff650e8756c45f0f0e"
../target/release/test_results \
--data-type krdanta \
--test-cases test-files/krdantas-yan-luk.csv \
--hash "7e28699c1de0739c567b6007cad110487f59a8bbb3ecad31cc51b990840b6a08"
--hash "ad5d53cf24b411e0b9ffbf7a95ee36113d76551ddef0ce06128fb44e436570a1"

test_dhatus:
cargo build --release --bin test_results
../target/release/test_results \
--data-type dhatu \
--test-cases test-files/dhatus.csv \
--hash "0b91b392570b0e08aa4d0373f45f7c28c00abcdb8fde05bd1871d7da26d3efa1"
--hash "aef40ba22893ed6d6c7fd7c126b93435faa9418491002b1dc8ae895c7a6e28e8"


test_subantas:
Expand Down
71 changes: 40 additions & 31 deletions vidyut-prakriya/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ An online demo is available [here][demo].

- [Overview](#overview)
- [Usage](#usage)
- [Contributing](#contributing)
- [Data](#data)
- [Design](#design)
- [Reporting errors](#reporting-errors)
- [Contributing](#contributing)

[crate]: https://doc.rust-lang.org/book/ch07-01-packages-and-crates.html
[ambuda]: https://ambuda.org
Expand Down Expand Up @@ -163,22 +164,50 @@ Our test suite also contains numerous examples of invoking various parts of
directory.


Contributing
------------
Data
----

This crate includes a *Dhātupāṭha* sourced from [ashtadhyayi.com][a-com],
and the author of [ashtadhyayi.com][a-com] has graciously agreed to share this
file with us under an MIT license.

For details on the lineage of this *Dhātupāṭha*, see our separate [data
README][data-readme].

[a-com]: https://ashtadhyayi.com
[data-readme]: data/README.md


Design
------

See `ARCHITECTURE.md` for details.


Reporting errors
----------------

Reporting errors is one of the most valuable ways to improve `vidyut-prakriya`!

`vidyut-prakriya` is an ambitious project, and your contributions can help it
grow.
1. First, check that the error is present in recent builds of vidyut-prakriya.
This repo contains our most recent code, but the builds on [ashtadhyayi.com][a-com]
or our own [Vidyullekha][vidyullekha] are more convenient to use and are also
reasonably up to date.

### Reporting errors
2. If the error is still present, please [file a GitHub issue][gh-issue] and let
us know what you expected to see.

The easiest way to help is to [file a GitHub issue][gh-issue] if you notice an
error. Please let us know what form you expected to see. We would also greatly
appreciate relevant citations from the grammatical literature so that we can
better understand and resolve the issue.
3. If possible, please include citations from the grammatical literature so that we
can better understand and resolve the issue. The more citations you provide, the
faster we can fix the issue.

[a-com]: https://ashtadhyayi.com
[vidyullekha]: https://ambuda-org.github.io/vidyullekha/
[gh-issue]: https://github.com/ambuda-org/vidyut-pada-snapshot/issues

### Modifying the code

Contributing
------------

First, see if you can run our existing code on your machine. We suggest
that you start by running our integration tests:
Expand Down Expand Up @@ -219,23 +248,3 @@ $ make test_all
`make test_all` should fail on a hash comparison error. Copy the new hash code,
replace the existing hash code in the `test_all` in our `Makefile` with that
copied value. Then, run `make test_all` again and confirm that all tests pass.


Data
----

This crate includes a *Dhātupāṭha* sourced from [ashtadhyayi.com][a-com],
and the author of [ashtadhyayi.com][a-com] has graciously agreed to share this
file with us under an MIT license.

For details on the lineage of this *Dhātupāṭha*, see our separate [data
README][data-readme].

[a-com]: https://ashtadhyayi.com
[data-readme]: data/README.md


Design
------

See `ARCHITECTURE.md` for details.
18 changes: 9 additions & 9 deletions vidyut-prakriya/data/dhatupatha.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ code dhatu artha
01.0376 luqi~ steye
01.0377 vawi~ viBAjane
01.0378 sPawi~ viSaraRe
01.0379 Puwi~r viSaraRe
01.0379 sPuwi~r viSaraRe
01.0380 sPuwi~ viSaraRe
01.0381 paWa~ vyaktAyAM vAci
01.0382 vaWa~ sTOlye
Expand Down Expand Up @@ -810,7 +810,7 @@ code dhatu artha
01.0809 hlasa~ Sabde
01.0810 rasa~ Sabde
01.0811 lasa~ SlezaRakrIqanayoH
01.0812 Gasx~ adane
01.0812 Ga\sx~ adane
01.0813 jarja~ pariBAzaRahiMsAtarjanezu
01.0814 carca~ pariBAzaRahiMsAtarjanezu
01.0815 JarJa~ pariBAzaRahiMsAtarjanezu
Expand Down Expand Up @@ -2095,10 +2095,10 @@ code dhatu artha
10.0344 vfjI~ varjane
10.0345 vfY AvaraRe
10.0346 jF vayohAnO
10.0347 jri vayohAnO
10.0348 rica~ viyojanasamparcanayoH
10.0349 Siza~ asarvopayoge
10.0350 tapa~ dAhe
10.0347 jri\ vayohAnO
10.0348 ri\ca~ viyojanasamparcanayoH
10.0349 Si\za~ asarvopayoge
10.0350 ta\pa~ dAhe
10.0351 tfpa~ tfptO sandIpane prIRane ca
10.0352 CfdI~ sandIpane
10.0353 cfpa~ sandIpane
Expand All @@ -2109,14 +2109,14 @@ code dhatu artha
10.0358 dfBa~ sandarBe
10.0359 lawa~ BAzAyAm
10.0360 SraTa~ mokzaRe hiMsAyAM ca
10.0361 mI gatO
10.0361 mI\ gatO
10.0362 granTa~ banDane
10.0363 SIka~ AmarzaRe
10.0364 cIka~ AmarzaRe
10.0365 arda~^ hiMsAyAm
10.0366 hisi~ hiMsAyAm
10.0367 arha~ pUjAyAm
10.0368 zada~ padyarTe
10.0368 za\da~ padyarTe
10.0369 SunDa~ SOcakarmaRi
10.0370 Cada~ apavAraRe
10.0371 juza~ paritarkaRe paritarpaRe ca
Expand All @@ -2128,7 +2128,7 @@ code dhatu artha
10.0377 tanu~ SradDopakaraRayoH
10.0378 cana~ SradDopahananayoH
10.0379 vada~^ sandeSavacane
10.0380 vaca~ pariBAzaRe
10.0380 va\ca~ pariBAzaRe
10.0381 mAna~ pUjAyAm
10.0382 BU prAptO
10.0383 garha~ vinindane
Expand Down
1 change: 1 addition & 0 deletions vidyut-prakriya/data/varttikas.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
7.4.3.1 kARyAdInAM ceti vaktavyam
7.4.30.1 hanterhisAyAM yaNi GnIBAvo vaktavyaH
7.4.54.1 sani rADo hiMsAyAmaca is vaktavyaH
7.4.85.1 padAntavacceti vaktavyam
7.4.90.1 rIgftvata iti vaktavyam
8.2.8.1 NAvuttarapade pratizeDasya pratizeDo vaktavyaH
8.2.8.3 vA napuMsakAnAm iti vaktavyam
Expand Down
35 changes: 22 additions & 13 deletions vidyut-prakriya/examples/create_tinantas_babylon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! ```
use clap::Parser;
use vidyut_lipi::{transliterate, Mapping, Scheme};
use vidyut_lipi::{Lipika, Scheme};
use vidyut_prakriya::args::*;
use vidyut_prakriya::dhatupatha::Entry as DhatuEntry;
use vidyut_prakriya::{Dhatupatha, Vyakarana};
Expand All @@ -44,9 +44,8 @@ struct BabylonEntry {
html_row: String,
}

fn to_devanagari(text: &str) -> String {
let mapping = Mapping::new(Scheme::Slp1, Scheme::Devanagari);
transliterate(&text, &mapping)
fn to_devanagari(lipika: &mut Lipika, text: &str) -> String {
lipika.transliterate(&text, Scheme::Slp1, Scheme::Devanagari)
}

/// Removes svarita and anudAtta from the dhatu (for easier searching)
Expand All @@ -58,6 +57,7 @@ fn replace_svaras(text: &str) -> String {
/// not be created.
fn create_entry(
v: &Vyakarana,
lipika: &mut Lipika,
dhatu_entry: &DhatuEntry,
sanadi: Option<Sanadi>,
prayoga: Prayoga,
Expand All @@ -80,7 +80,7 @@ fn create_entry(
for p in prakriyas {
let human_dhatu = p.text();
if !search_row.is_empty() {
search_row += "|";
search_row += "_";
}
search_row += &human_dhatu;

Expand All @@ -99,7 +99,7 @@ fn create_entry(
for p in prakriyas {
let human_dhatu = p.text();
if !search_row.is_empty() {
search_row += "|";
search_row += "_";
}
search_row += &human_dhatu;

Expand Down Expand Up @@ -134,8 +134,8 @@ fn create_entry(
_ => return None,
};
html_row += ")";
search_row = to_devanagari(&search_row);
html_row = to_devanagari(&html_row);
search_row = to_devanagari(lipika, &search_row).replace("_", "|");
html_row = to_devanagari(lipika, &html_row);

html_row += "<br>";

Expand Down Expand Up @@ -167,17 +167,17 @@ fn create_entry(

for pada in &padas {
search_row += "|";
search_row += &to_devanagari(&pada);
search_row += &to_devanagari(lipika, &pada);
}

html_row += "<br>";
let mut added_one = false;
for pada in &padas {
if added_one {
html_row += " / ";
html_row += &to_devanagari(&pada);
html_row += &to_devanagari(lipika, &pada);
} else {
html_row += &to_devanagari(&pada);
html_row += &to_devanagari(lipika, &pada);
added_one = true;
}
}
Expand All @@ -201,6 +201,7 @@ fn create_entry(
fn run(dp: Dhatupatha, args: Args) {
// Disable `log_steps` so that we can generate words more quickly.
let v = Vyakarana::builder().log_steps(false).build();
let mut lipika = Lipika::new();

let prayoga = match args.prayoga {
Some(p) => p,
Expand All @@ -219,15 +220,23 @@ fn run(dp: Dhatupatha, args: Args) {
}

let mut description = String::new();
description += &to_devanagari(&args.desc);
description += &to_devanagari(&mut lipika, &args.desc);
description += " (https://ambuda-org.github.io/vidyullekha/)";
println!("#description={description}\n");

// Entries
for dhatu_entry in dp {
for lakara in Lakara::iter() {
for pada in &[DhatuPada::Parasmai, DhatuPada::Atmane] {
let entry = create_entry(&v, &dhatu_entry, args.sanadi, prayoga, *pada, lakara);
let entry = create_entry(
&v,
&mut lipika,
&dhatu_entry,
args.sanadi,
prayoga,
*pada,
lakara,
);
if let Some(e) = entry {
print!("{}\n{}\n\n", e.search_row, e.html_row);
}
Expand Down
Loading

0 comments on commit c0fa416

Please sign in to comment.