平方X

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3817|回复: 1

[2365]修改OmegaT的模糊匹配填入规则

[复制链接]

414

主题

709

帖子

3602

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3602
QQ
发表于 2017-9-13 15:58:28 | 显示全部楼层 |阅读模式
[md]
>本文由平方X发表于平方X网,转载请注明出处。[http://blog.pingfangx.com/2365.html](http://blog.pingfangx.com/2365.html)

# 0x01 修改自动填入
OmegaT支持模糊匹配,并且可以设置自动插入匹配的项。  
但是有一个问题,就是在有数字符号的时候,它会忽略,仍计算为匹配。  
在[官方帮助文档中]我们知道
>实际上还有三个可用的匹配估计(在上面第4个匹配中为66/66/30)。它们的含义如下:
>* 使用解析器插件后的匹配百分率
>* 缺省的OmegaT匹配度,即忽略数字和标签后匹配词汇数除以总的词汇数
>* 包含数字、标签的OmegaT匹配度
```
org.omegat.Main.main(String[])
org.omegat.Main.runGUI()
org.omegat.core.Core.initializeGUI(Map<String, String>)
org.omegat.gui.matches.MatchesTextArea.checkForReplaceTranslation()


            if (thebest.scores[0].score >= percentage) {
改为
            if (thebest.scores[0].adjustedScore >= percentage) {
```

# 0x02 修改差异显示
```
org.omegat.gui.common.EntryInfoSearchThread#run
    1搜索
    org.omegat.gui.common.EntryInfoSearchThread#search
    org.omegat.gui.matches.FindMatchesThread#search
    org.omegat.core.statistics.FindMatches#search
        1.1 处理
        org.omegat.core.statistics.FindMatches#processEntry
        org.omegat.core.statistics.FindMatches#addNearString
        
        1.2 处理数据
        org.omegat.core.matching.FuzzyMatcher#buildSimilarityData

    2处理结果
    org.omegat.gui.matches.MatchesTextArea#setFoundResult
    在 org.omegat.gui.matches.MatchesTextArea#setActiveMatch
    通过 javax.swing.text.StyledDocument#setCharacterAttributes 设置
```

# 0x03 Talk is cheap
[code](https://github.com/pingfangx/omegat/commit/25a30b6dddc56dc7f1205e241eb7cad49a6051be)[/md]
我是平方X~
回复

使用道具 举报

0

主题

2

帖子

20

积分

标准X

Rank: 1

积分
20
发表于 2018-6-11 17:20:25 | 显示全部楼层
学习了!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|平方X ( 冀ICP备14018164号 )

GMT+8, 2024-4-19 20:41 , Processed in 0.124711 second(s), 21 queries .

技术支持:Powered by Discuz!X3.4  © 2001-2013 Comsenz Inc.

版权所有:Copyright © 2014-2018 平方X www.pingfangx.com All rights reserved.

快速回复 返回顶部 返回列表