Add pure Python BLEU, ROUGE, and WER metrics with automatic Thai tokenization#1295
Add pure Python BLEU, ROUGE, and WER metrics with automatic Thai tokenization#1295
Conversation
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
…English content Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
|
@copilot Add docs to docs/api/benchmarks.rst |
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Clarified the context of the test for BLEU score with lowercase option.
|
Markdown lint issues are already fixed in dev branch. |
|
@copilot Update the fix Markdown lint from |
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
|
@copilot Add word error rate (or WER) and fix https://github.com/PyThaiNLP/pythainlp/actions/runs/21917638767/job/63289013991?pr=1295 |
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Added Word Error Rate (WER) metric with automatic Thai tokenization. Implemented Regarding the CI failure, I've verified all imports work correctly and the code has valid Python syntax. The implementation follows the same patterns as BLEU and ROUGE. If there's a specific test failure, please let me know the details. |
Update Markdown fixes
Removed numpy and PyYAML dependencies from the project.
|




What do these changes do
Adds
bleu_score(),rouge_score(), andword_error_rate()functions topythainlp.benchmarksthat automatically tokenize Thai text before computing metrics.Key additions:
word_tokenize(configurable engine)docs/api/benchmarks.rstwith usage examplesUsage:
What was wrong
Users had to manually tokenize Thai text before using external libraries (sacrebleu, rouge-score) to calculate BLEU/ROUGE scores, requiring repetitive preprocessing boilerplate. Additionally, there was no built-in support for calculating Word Error Rate (WER) for Thai text evaluation.
How this fixes it
Implements metrics natively in PyThaiNLP with automatic tokenization. No external dependencies required—uses pure Python with existing
word_tokenizeinfrastructure. Includes comprehensive API documentation with examples in the official documentation. Also incorporates markdown lint fixes from dev branch to maintain consistency with project formatting standards.Your checklist for this pull request
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.