Skip to content

Commit

Permalink
[prakriya] Clean up various code
Browse files Browse the repository at this point in the history
Changes include:
- Rename two `Prakriya` methods: `op` to `run` and `op_term` to `run_at`.
- Standardize on `CharPrakriya` when working with characters.
- Reduce use of `has_tag` in favor of methods like `has_abhyasa`.
- Simplify various testing functions for readability and ease of use.
- Add more docstrings and comments.
- Add other small fixes.
  • Loading branch information
akprasad committed Oct 29, 2023
1 parent f87be43 commit 9441bbd
Show file tree
Hide file tree
Showing 72 changed files with 2,909 additions and 2,610 deletions.
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vidyut-prakriya/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edition = "2021"
clap = { version = "4.0.12", features = ["derive"] }
compact_str = { version = "0.6.1", features = ["serde"] }
csv = "1.1.6"
enumset = { version = "1.0.12", features = ["serde"] }
enumset = { version = "1.1.3", features = ["serde"] }
lazy_static = "1.4.0"
serde = { version = "1.0.150", features = ["derive"] }
sha2 = "0.10.6"
Expand Down
2 changes: 1 addition & 1 deletion vidyut-prakriya/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ check_rule_coverage:
# Profiles the program's execution time on OSX. This command will probably not
# work on other operating systems.
profile-time-osx:
cargo instruments -t time --release --bin create_test_files
cargo instruments -t time --release --bin create_test_file


# Other
Expand Down
8 changes: 4 additions & 4 deletions vidyut-prakriya/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ fn rules(p: &mut Prakriya, i: usize) -> Option<()> {
if base.has_tag(T::Abhyasta) {
// juhvati
p.op_term("7.1.4", i, op::adi("at"));
p.run_at("7.1.4", i, op::adi("at"));
} else if !base.has_antya('a') && tin.has_tag(T::Atmanepada) {
// kurvate
p.op_term("7.1.5", i, op::adi("at"));
p.run_at("7.1.5", i, op::adi("at"));
} else {
// Bavanti
p.op_term("7.1.3", i, op::adi("ant"));
p.run_at("7.1.3", i, op::adi("ant"));
}
Some(())
Expand All @@ -266,7 +266,7 @@ they don't sacrifice readability. Some notes on our naming conventions:

Notes on our API:

- `p.op_term("my-rule", i, fn)` applies the `fn` function to the term at index `i`
- `p.run_at("my-rule", i, fn)` applies the `fn` function to the term at index `i`
of `p` and associates that operation with `"my-rule"`.
- `op::adi(s)` returns a function. The returned function accepts a `Term` and
replaces its first sound with `s`. If you haven't worked with [first-class
Expand Down
Loading

0 comments on commit 9441bbd

Please sign in to comment.