| """ |
| 单元测试 — 评估模块 (Person D 实现后需通过) |
| """ |
|
|
| import pytest |
| import torch |
|
|
|
|
| class TestMetrics: |
| """测试评估指标。""" |
|
|
| def test_bleu_perfect(self): |
| """完美翻译的 BLEU 应接近 100。""" |
| pass |
|
|
| def test_bleu_zero(self): |
| """完全不相关的翻译 BLEU 应接近 0。""" |
| pass |
|
|
| def test_chrf_score(self): |
| """测试 chrF 分数范围合理。""" |
| pass |
|
|
|
|
| class TestDecoding: |
| """测试解码策略。""" |
|
|
| def test_greedy_decode_shape(self): |
| """测试贪心解码输出维度。""" |
| pass |
|
|
| def test_greedy_produces_eos(self): |
| """测试贪心解码能生成 EOS。""" |
| pass |
|
|
| def test_beam_search_better_than_greedy(self): |
| """束搜索质量应不低于贪心。""" |
| pass |
|
|
| def test_no_repeat_ngram(self): |
| """测试 n-gram 不重复约束。""" |
| pass |
|
|
|
|
| class TestEvaluator: |
| """测试评估器。""" |
|
|
| def test_translate_single(self): |
| """测试单句翻译。""" |
| pass |
|
|
| def test_translate_batch(self): |
| """测试批量翻译。""" |
| pass |
|
|