Skip to content

Commit

Permalink
[prakriya] Add support for Ayiyat, etc.
Browse files Browse the repository at this point in the history
This fixes GitHub issue #120.
  • Loading branch information
akprasad committed Jun 2, 2024
1 parent c3aa648 commit 2be2744
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion vidyut-prakriya/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test_tinantas:
--hash "28293a6aa746f04dff1a5c3b822396c236df269460d691bd137ba01a2c80557f"
../target/release/test_tinantas \
--test-cases test-files/tinantas-nic-kartari.csv \
--hash "5d508a8b3a52ebe92a1524b0b51bbed90e27301f265669aa8e7a887d55bf1eff"
--hash "e4ab38f9c71d040bf8cbf7dbc6bb1951749b831240f9248288389a68b24ef413"
../target/release/test_tinantas \
--test-cases test-files/tinantas-san-kartari.csv \
--hash "ef278531cd45ba1df9af60e5b4b8ef582fdbe7a7eb31478fe35b9600c42380fc"
Expand Down
7 changes: 6 additions & 1 deletion vidyut-prakriya/src/dvitva.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use lazy_static::lazy_static;

lazy_static! {
static ref AC: Set = s("ac");
static ref YAN: Set = s("yaR");
static ref HAL: Set = s("hal");
static ref NDR: Set = s("n d r");
}
Expand Down Expand Up @@ -61,7 +62,12 @@ fn mark_abhyasta(p: &mut Prakriya, i_start: usize, i_end: usize) {
fn try_dvitva(rule: Code, p: &mut Prakriya, i_dhatu: usize) -> Option<()> {
// First, run ac-sandhi (for div -> dudyUzati, etc.)
ac_sandhi::run_antaranga(p);

p.maybe_save_sthanivat();
// Force-save for dhatus that consist of a single vowel.
if p.has(i_dhatu, |t| t.has_adi(&*AC) && t.has_antya(&*YAN)) {
p.set(i_dhatu, |t| t.force_save_sthanivat());
}

let i_n = p.find_next_where(i_dhatu, |t| {
!(t.is_agama() && t.has_tag(T::kit) && !t.is_it_agama())
Expand Down Expand Up @@ -252,7 +258,6 @@ fn try_dvitva(rule: Code, p: &mut Prakriya, i_dhatu: usize) -> Option<()> {
///
/// - `i` should point to a dhatu.
fn run_at_index(p: &mut Prakriya, i: usize) -> Option<()> {
p.debug("run at index");
let dhatu = p.get_mut(i)?;
debug_assert!(dhatu.is_dhatu());

Expand Down
17 changes: 17 additions & 0 deletions vidyut-prakriya/tests/regressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,20 @@ fn irshy_san_lan() {
&["Erzyiyizat", "Erzyizizat"],
);
}

// Fixes https://github.com/ambuda-org/vidyut/issues/120
#[test]
fn ayiyat() {
assert_has_tip(&[], &nic(&d("I\\N", Divadi)), Lun, &["Ayiyat"]);
}

// Fixes https://github.com/ambuda-org/vidyut/issues/121
#[test]
fn adhyajigapat_adhyapipat() {
assert_has_tip(
&["aDi"],
&nic(&d("i\\N", Adadi)),
Lun,
&["aDyajIgapat", "aDyApipat"],
);
}

0 comments on commit 2be2744

Please sign in to comment.