Feat: Implement Word Error Rate (WER) metric
🚀 Feature: WER and CER Metrics
Resolves #3634
This PR implements \WordErrorRate\ and \CharacterErrorRate\ natively within \ignite.metrics.nlp\ to evaluate ASR and OCR models, using an internal, dependency-free Levenshtein distance calculation to remain lightweight.
Changes:
- Added robust Levenshtein Distance dynamic programming solver.
- Implemented \WordErrorRate\ which splits strings via tokens to compute word-level permutations.
- Implemented \CharacterErrorRate\ which computes exact string edit distance.
- Integrated the new classes into the \ignite.metrics.nlp\ initializers.
- Provided 100% test coverage mimicking existing Pytest tests in Ignite.
I have updated the implementation to split the WER and CER metrics into separate files (word_error_rate.py and character_error_rate.py) and organized the tests accordingly, as suggested. This maintains consistency with the existing codebase conventions (similar to Bleu and Rouge). All tests for both metrics are passing.
@Manimaran-tech if you would like to move forward with this PR, let's split it into 2: one PR per one metric
Hi @Manimaran-tech — the maintainer suggested I check with you before moving forward with my CER PR (#3785). Are you still planning to submit a separate CER implementation as a follow-up to your WER PR? Happy to coordinate or defer if you're actively working on it.