Trados Studio | 时刻的正则验证

本文介绍了如何利用正则表达式在Trados Studio中进行QA检查,确保12小时制时间的翻译符合特定风格指南。通过编写一系列复杂的正则规则,可以验证诸如午夜、早上、下午等不同时刻的正确翻译,提高翻译质量。
部署运行你感兴趣的模型镜像


如果 QA 工具运用得当,可将翻译中的低错降至最低程度。而正则表达式则是 QA 工具中的利器。现在就通过一个数字验证实例说明如何巧用正则表达式提高工作效率。

根据翻译风格指南,一天中的时刻如果是 12 小时制,则翻译须遵循以下规则:

```
12:00 a.m. -> 午夜 12:00
12:59 a.m. -> 午夜 12:59
1:00 a.m. -> 午夜 1:00
5:59 a.m. -> 午夜 5:59
6:00 a.m. -> 早上 6:00
8:59 a.m. -> 早上 8:59
9:00 a.m. -> 上午 9:00
11:59 a.m. -> 上午 11:59
12:00 p.m. -> 中午 12:00
12:59 p.m. -> 中午 12:59
1:00 p.m. -> 下午 1:00
6:59 p.m. -> 下午 6:59
7:00 p.m. -> 晚上 7:00
11:59 p.m. -> 晚上 11:59
```

其中小时和分钟之间的分隔符可能是单字节冒号或句号,am 可能有各种变体,如 a.m./a.m/am./AM/A.M/AM./aM/Am/aM./A.m...。pm 也是一样。

由于不同时刻,am/pm 需要翻译成不同译文,因此批量替换是不可能的。

如何验证最终译文完全遵循了风格指南呢?答案是正则验证。这么复杂的要求,只有编写一系列正则表达式,才能保证万无一失。

按照风格指南,编写的正则验证规则如下:

```
12(\.|:)(\d{1,2}) ?p(\.)?m(\.)?    中午 12:$2        GroupedSourceNotTarget    
12(\.|:)(\d{1,2}) ?a(\.)?m(\.)?    午夜 12:$2        GroupedSourceNotTarget    
\b(0?[1-5]{1})(\.|:)(\d{1,2}) ?a(\.)?m(\.)?    午夜 $1:$3        GroupedSourceNotTarget    
\b(0?[6-8]{1})(\.|:)(\d{1,2}) ?a(\.)?m(\.)?    早上 $1:$3        GroupedSourceNotTarget    
\b(0?(9|10|11){1})(\.|:)(\d{1,2}) ?a(\.)?m(\.)?    上午 $1:$4        GroupedSourceNotTarget    
\b(0?[1-6]{1})(\.|:)(\d{1,2}) ?p(\.)?m(\.)?    下午 $1:$3        GroupedSourceNotTarget    
\b((0?[7-9]{1})|((10|11){1}))(\.|:)(\d{1,2}) ?p(\.)?m(\.)?    晚上 $1:$6        GroupedSourceNotTarget    
```

将此文本保存为 .csv 格式,然后用转换工具将其转为 .sdlqasettings 格式,即可导入 Trados Studio。

转换后的 .sdlqasettings 格式内容如下:

```
<?xml version="1.0" encoding="utf-8"?>
<SettingsBundle>
    <SettingsGroup Id="QAVerificationSettings">
        <Setting Id="RegExRules">True</Setting>
        <Setting Id="RegExRulesCount">7</Setting>
        <Setting Id="RegExRules0">
            <RegExRule
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://schemas.datacontract.org/2004/07/Sdl.Verification.QAChecker.RegEx">
                <Description>Source ‹12(\.|:)(\d{1,2}) ?p(\.)?m(\.)?› matched but not target ‹中午 12:$2›</Description>
                <IgnoreCase>true</IgnoreCase>
                <RegExSource>12(\.|:)(\d{1,2}) ?p(\.)?m(\.)?</RegExSource>
                <RegExTarget>中午 12:$2</RegExTarget>
                <RuleCondition>GroupedSourceNotTarget</RuleCondition>
            </RegExRule>
        </Setting>
        <Setting Id="RegExRules1">
            <RegExRule
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://schemas.datacontract.org/2004/07/Sdl.Verification.QAChecker.RegEx">
                <Description>Source ‹12(\.|:)(\d{1,2}) ?a(\.)?m(\.)?› matched but not target ‹午夜 12:$2›</Description>
                <IgnoreCase>true</IgnoreCase>
                <RegExSource>12(\.|:)(\d{1,2}) ?a(\.)?m(\.)?</RegExSource>
                <RegExTarget>午夜 12:$2</RegExTarget>
                <RuleCondition>GroupedSourceNotTarget</RuleCondition>
            </RegExRule>
        </Setting>
        <Setting Id="RegExRules2">
            <RegExRule
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://schemas.datacontract.org/2004/07/Sdl.Verification.QAChecker.RegEx">
                <Description>Source ‹\b(0?[1-5]{1})(\.|:)(\d{1,2}) ?a(\.)?m(\.)?› matched but not target ‹午夜 $1:$3›</Description>
                <IgnoreCase>true</IgnoreCase>
                <RegExSource>\b(0?[1-5]{1})(\.|:)(\d{1,2}) ?a(\.)?m(\.)?</RegExSource>
                <RegExTarget>午夜 $1:$3</RegExTarget>
                <RuleCondition>GroupedSourceNotTarget</RuleCondition>
            </RegExRule>
        </Setting>
        <Setting Id="RegExRules3">
            <RegExRule
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://schemas.datacontract.org/2004/07/Sdl.Verification.QAChecker.RegEx">
                <Description>Source ‹\b(0?[6-8]{1})(\.|:)(\d{1,2}) ?a(\.)?m(\.)?› matched but not target ‹早上 $1:$3›</Description>
                <IgnoreCase>true</IgnoreCase>
                <RegExSource>\b(0?[6-8]{1})(\.|:)(\d{1,2}) ?a(\.)?m(\.)?</RegExSource>
                <RegExTarget>早上 $1:$3</RegExTarget>
                <RuleCondition>GroupedSourceNotTarget</RuleCondition>
            </RegExRule>
        </Setting>
        <Setting Id="RegExRules4">
            <RegExRule
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://schemas.datacontract.org/2004/07/Sdl.Verification.QAChecker.RegEx">
                <Description>Source ‹\b(0?(9|10|11){1})(\.|:)(\d{1,2}) ?a(\.)?m(\.)?› matched but not target ‹上午 $1:$4›</Description>
                <IgnoreCase>true</IgnoreCase>
                <RegExSource>\b(0?(9|10|11){1})(\.|:)(\d{1,2}) ?a(\.)?m(\.)?</RegExSource>
                <RegExTarget>上午 $1:$4</RegExTarget>
                <RuleCondition>GroupedSourceNotTarget</RuleCondition>
            </RegExRule>
        </Setting>
        <Setting Id="RegExRules5">
            <RegExRule
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://schemas.datacontract.org/2004/07/Sdl.Verification.QAChecker.RegEx">
                <Description>Source ‹\b(0?[1-6]{1})(\.|:)(\d{1,2}) ?p(\.)?m(\.)?› matched but not target ‹下午 $1:$3›</Description>
                <IgnoreCase>true</IgnoreCase>
                <RegExSource>\b(0?[1-6]{1})(\.|:)(\d{1,2}) ?p(\.)?m(\.)?</RegExSource>
                <RegExTarget>下午 $1:$3</RegExTarget>
                <RuleCondition>GroupedSourceNotTarget</RuleCondition>
            </RegExRule>
        </Setting>
        <Setting Id="RegExRules6">
            <RegExRule
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
                xmlns="http://schemas.datacontract.org/2004/07/Sdl.Verification.QAChecker.RegEx">
                <Description>Source ‹\b((0?[7-9]{1})|((10|11){1}))(\.|:)(\d{1,2}) ?p(\.)?m(\.)?› matched but not target ‹晚上 $1:$6›</Description>
                <IgnoreCase>true</IgnoreCase>
                <RegExSource>\b((0?[7-9]{1})|((10|11){1}))(\.|:)(\d{1,2}) ?p(\.)?m(\.)?</RegExSource>
                <RegExTarget>晚上 $1:$6</RegExTarget>
                <RuleCondition>GroupedSourceNotTarget</RuleCondition>
            </RegExRule>
        </Setting>
    </SettingsGroup>
</SettingsBundle>
```

导入 Trados Studio 后,测试一下,效果如下:

![Trados Studio QA results](https://img.pharmeditrans.com/time_veri_by_regex.PNG)
 

您可能感兴趣的与本文相关的镜像

ComfyUI

ComfyUI

AI应用
ComfyUI

ComfyUI是一款易于上手的工作流设计工具,具有以下特点:基于工作流节点设计,可视化工作流搭建,快速切换工作流,对显存占用小,速度快,支持多种插件,如ADetailer、Controlnet和AnimateDIFF等

评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值