feat: Add Rust unit tests to CI pipeline (closes #71)#72
Open
ada-cinar wants to merge 14 commits into
Open
Conversation
- Add gold-standard test set with 73 Turkish word-lemma pairs - Create evaluate_lemmatizer.py script for strategy comparison - Implement baseline storage for regression detection - Achieve 97.3% accuracy with lookup/hybrid strategies - Add comprehensive evaluation documentation Resolves #56
- Expand gold_standard.tsv to 109 test cases (100+ requirement met) - Add conditional tense, imperatives, participles - Add proper nouns with apostrophes - Add compound words and complex suffix chains - Add adjective-to-noun derivations - Update baseline metrics (lookup: 68.8%, hybrid: 69.7%, heuristic: 18.3%) - Lower accuracy reflects more challenging test set - Better represents real-world lemmatization complexity - Add CI regression testing to .github/workflows/tests.yml - Fails build if accuracy drops >5% from baseline - Runs on Python 3.11 after unit tests - Document strategy selection in BEST_PRACTICES.md - Add comparison table with accuracy benchmarks - Provide usage guidelines for each strategy - Include custom dataset evaluation instructions All success criteria from issue #56 now met: ✅ 100+ hand-curated test pairs ✅ Evaluation script with metrics ✅ Baseline metrics stored ✅ CI job for regression detection ✅ Strategy comparison documentation
- Add LemmatizerMetrics dataclass with performance tracking - Call counts (total, lookup hits/misses, heuristic calls) - Timing metrics (total, lookup, heuristic time) - Computed properties (cache hit rate, avg call time) - Extend Lemmatizer class with metrics support - collect_metrics parameter (default: False, zero overhead) - get_metrics() and reset_metrics() methods - Per-call timing instrumentation using perf_counter - Updated __repr__ to show metrics status - Add comprehensive test suite - 11 new tests covering all metrics scenarios - Tests for lookup, heuristic, hybrid strategies - Timing validation, reset functionality - Computed properties verification - Add interactive demo script - examples/lemmatizer_metrics_demo.py - Basic metrics collection example - Strategy comparison benchmark - Large corpus performance test - Incremental monitoring demo - Export LemmatizerMetrics in __init__.py Benefits: ✅ Data-driven strategy selection ✅ Performance debugging and profiling ✅ Research reproducibility ✅ Production monitoring capability ✅ Zero overhead when disabled Related to #56 (Lemma Evaluation Framework) - metrics enable deeper performance analysis during evaluation.
- Add new Lemmatization section with strategy overview - Document performance metrics collection feature - Add usage examples for metrics and strategy comparison - Reference example demo script Completes documentation for issue #63
Improve metrics collection pattern in Lemmatizer: - Replace 'if self.collect_metrics' with 'if self._metrics is not None' - More robust and idiomatic pattern - Avoids potential state inconsistencies - All metrics tests passing (11/11) Related to #63
- Add 'cargo test --all-features' step to run Rust unit tests (6 tests) - Add 'cargo clippy -- -D warnings' for Rust linting - Add 'cargo fmt --check' for Rust code formatting validation - Run Rust checks before Python tests to catch core issues early - Format Rust code with 'cargo fmt' (whitespace/import order fixes) Benefits: ✅ Catch Rust-level bugs in CI (lemma dict, normalization, suffix stripping) ✅ Enforce code quality standards (clippy warnings) ✅ Ensure consistent formatting (rustfmt) ✅ Prevent resource loading regressions Closes #71
Member
|
@copilot fix the conflict errors if possible |
Contributor
|
@fbkaragoz I've opened a new pull request, #137, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: fbkaragoz <59958216+fbkaragoz@users.noreply.github.com>
Co-authored-by: fbkaragoz <59958216+fbkaragoz@users.noreply.github.com>
Co-authored-by: fbkaragoz <59958216+fbkaragoz@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #71
Summary
Adds Rust unit tests, clippy linting, and code formatting checks to the CI/CD pipeline, ensuring Rust core quality is validated before merge.
Changes
1. Rust Unit Tests
cargo test --all-featuressteptest_lemma_dict_loadingtest_lookup_lemma_high_frequency_nounstest_lookup_lemma_high_frequency_verbstest_lookup_lemma_oov_wordstest_lemma_dict_format_validationtest_strip_suffixes_basic2. Rust Linting (Clippy)
cargo clippy -- -D warnings3. Rust Formatting (rustfmt)
cargo fmt --checkcargo fmttosrc/lib.rs(whitespace/import order fixes)4. CI Execution Order
Local Testing
All checks pass:
Benefits
Related Issues
Checklist
cargo teststep to.github/workflows/tests.ymlcargo clippyfor Rust lintingcargo fmt --checkfor Rust formattingReady for review! 🚀