Skip to content

Commit

Permalink
[prakriya] Add various Siddhanta Kaumudi tests
Browse files Browse the repository at this point in the history
These tests focus on prakaranas 43 to 52, which describe the ten dhatu
gana. Much more work is necessary, but this is a substantial start, and
it has already uncovered many errors that this commit fixes.
  • Loading branch information
akprasad committed Oct 11, 2023
1 parent 19e34ce commit d1a03e2
Show file tree
Hide file tree
Showing 97 changed files with 13,108 additions and 1,843 deletions.
14 changes: 7 additions & 7 deletions vidyut-prakriya/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,28 @@ test_tinantas:
cargo build --release
../target/release/test_tinantas \
--test-cases test-files/tinantas-basic-kartari.csv \
--hash "cd93ffe7ac09925f21a26e23524e8a03aebffc2b1809c5480f4d3e70d7380281"
--hash "f8934f99631e811c333c41ddd4925229d2faab0dd875bc549bb38350319706db"
../target/release/test_tinantas \
--test-cases test-files/tinantas-nic-kartari.csv \
--hash "409c5efa5dbcebba7375732a64867f7212ee43d3b112c8c8c494099158e68a0a"
--hash "5e173e6665872f205f8c6ca2addc166e221f0d435b800dee4360116d0a8af69b"
../target/release/test_tinantas \
--test-cases test-files/tinantas-san-kartari.csv \
--hash "ec5acedd0e7a5ca478c9ede25ce69daa1f1acaeb7d161c1565e7c505cd843c55"
--hash "a4bce1c19d54ea2246429dbd345acaca24c380ac3b8c888ddb442e9d862af679"
../target/release/test_tinantas \
--test-cases test-files/tinantas-yan-kartari.csv \
--hash "71cf9817679767971c06bcb806b61f91d29402f27f158837425e02a67a5c0a01"
--hash "b8c4b3cf7a7e5572af8a1290118f629fbf6812925fe6a41bf9ffadb47a658446"
../target/release/test_tinantas \
--test-cases test-files/tinantas-basic-karmani.csv \
--hash "e3882dda3c9e1d82062fe12bf406bca99390f9a1bb6f4d58472e2dd19a2fdfef"
--hash "da0e4771bec284661bfd0f537734d44eb6e019e41a387e80dfaa80cf7dc27b03"

test_krdantas:
cargo build --release
../target/release/test_krdantas \
--test-cases test-files/krdantas-ktvA.csv \
--hash "a93a988a918d89b73febece101e04cf7a2032671cddea61bb5a3a8b22108a2a9"
--hash "13cd3088b99eeea4d30d91e58f28ad07e9082e6f92f122ff64f4c367dd4ff36c"
../target/release/test_krdantas \
--test-cases test-files/krdantas-kta.csv \
--hash "3aa1ced4d552d16109ee6ff1113469abc7eba19fd37a7a8bb94ba697746324fb"
--hash "650a4bc2e761f201389595785a5e6ab8a3023f657c58699aa269c01d28c75aae"

test_subantas:
cargo run --bin test_subantas -- \
Expand Down
8 changes: 4 additions & 4 deletions vidyut-prakriya/data/dhatupatha.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -1684,10 +1684,10 @@ code dhatu artha
09.0004 mI\Y hiMsAyAm
09.0005 zi\Y banDane
09.0006 sku\Y ApravaRe
09.0007 sta\nBu~ roDane stamBane ca
09.0008 stu\nBu~ roDane nizkozaRe ca
09.0009 ska\nBu~ roDane stamBane ca
09.0010 sku\nBu~ roDane DAraRe ca
09.0007 stanBu~ roDane stamBane ca
09.0008 stunBu~ roDane nizkozaRe ca
09.0009 skanBu~ roDane stamBane ca
09.0010 skunBu~ roDane DAraRe ca
09.0011 yu\Y banDane
09.0012 knUY Sabde
09.0013 drUY hiMsAyAm
Expand Down
9 changes: 9 additions & 0 deletions vidyut-prakriya/scripts/check_rule_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,22 @@ def print_legend():
tested_rules.add(m.group(1).replace('_', '.'))

print_legend()
num_ok = 0
num_untested = 0
num_missing = 0
for rule in all_rules:
status = None
if rule in tested_rules:
status = RULE_OK
num_ok += 1
elif rule in implemented_rules:
status = RULE_UNTESTED
num_untested += 1
else:
status = RULE_MISSING
num_missing += 1
print(f"{status}\t\t{rule}")
print_legend()
print(f"Num tested : {num_ok}")
print(f"Num untested : {num_untested}")
print(f"Num missing : {num_missing}")
24 changes: 18 additions & 6 deletions vidyut-prakriya/src/ac_sandhi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ pub fn try_lopo_vyor_vali(p: &mut Prakriya) {
}

fn try_ver_aprktasya(p: &mut Prakriya) -> Option<()> {
let i = p.find_last(T::Krt)?;
let krt = p.get(i)?;
if krt.has_text("v") {
let i = p.find_last(T::Pratyaya)?;
let last = p.get(i)?;
if last.has_text("v") {
p.op_term("6.1.67", i, op::lopa);
}

Expand Down Expand Up @@ -143,7 +143,7 @@ pub fn apply_general_ac_sandhi(p: &mut Prakriya) {
// upa + fcCati -> upArcCati
xy_rule(
p,
|x, y| x.has_tag(T::Upasarga) && x.has_antya(&*A) && y.is_dhatu() && y.has_adi('f'),
|x, y| x.is_upasarga() && x.has_antya(&*A) && y.is_dhatu() && y.has_adi('f'),
|p, i, j| {
p.set(i, |t| t.set_antya(""));
p.set(j, |t| t.set_adi("Ar"));
Expand All @@ -155,7 +155,7 @@ pub fn apply_general_ac_sandhi(p: &mut Prakriya) {
xy_rule(
p,
|x, y| {
x.has_tag(T::Upasarga)
x.is_upasarga()
&& x.has_antya(&*A)
&& y.has_u_in(&["i\\R", "eDa~\\"])
&& y.has_adi(&*EN)
Expand All @@ -168,10 +168,19 @@ pub fn apply_general_ac_sandhi(p: &mut Prakriya) {
},
);

// HACK for KOnAti
xy_rule(
p,
|x, _| x.has_text("KaU"),
|p, i, _| {
p.op_term("6.1.89", i, |t| t.set_text("KO"));
},
);

// upa + elayati -> upelayati
xy_rule(
p,
|x, y| x.has_tag(T::Upasarga) && x.has_antya(&*A) && y.is_dhatu() && y.has_adi(&*EN),
|x, y| x.is_upasarga() && x.has_antya(&*A) && y.is_dhatu() && y.has_adi(&*EN),
|p, i, _j| {
p.set(i, |t| t.set_antya(""));
p.step("6.1.94");
Expand Down Expand Up @@ -357,6 +366,9 @@ fn try_sut_kat_purva(p: &mut Prakriya) -> Option<()> {
} else if prev.has_u("apa") {
optional_add_sut("6.1.142", p, i_dhatu);
}
} else if prev.has_u("pra") && dhatu.has_u("tunpa~") {
optional_add_sut("6.1.157", p, i_dhatu);
// TODO: implement others.
}
Some(())
}
Expand Down
Loading

0 comments on commit d1a03e2

Please sign in to comment.