File size: 1,141 Bytes
c1a46f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
单元测试 — 评估模块 (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