Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply max penalty for sub-segment match #1223

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/org/omegat/core/statistics/FindMatches.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
2008 Alex Buloichik
2012 Thomas Cordonnier, Martin Fleurke
2013 Aaron Madlon-Kay, Alex Buloichik
2024 Hiroshi Miura
2024 Hiroshi Miura, Thomas Cordonnier
Home page: https://www.omegat.org/
Support center: https://omegat.org/support

Expand Down Expand Up @@ -271,6 +271,7 @@ public List<NearString> search(String searchText, boolean requiresTranslation, b
if (segments.size() > 1) {
List<String> fsrc = new ArrayList<>(segments.size());
List<String> ftrans = new ArrayList<>(segments.size());
int maxPenalty = 0;
// multiple segments
for (String onesrc : segments) {
// find match for a separate segment
Expand All @@ -280,6 +281,18 @@ public List<NearString> search(String searchText, boolean requiresTranslation, b
&& segmentMatch.get(0).scores[0].score >= SUBSEGMENT_MATCH_THRESHOLD) {
fsrc.add(segmentMatch.get(0).source);
ftrans.add(segmentMatch.get(0).translation);
if (segmentMatch.get(0).fuzzyMark) {
if (maxPenalty < PENALTY_FOR_FUZZY) {
maxPenalty = PENALTY_FOR_FUZZY;
}
}
Matcher matcher = SEARCH_FOR_PENALTY.matcher(segmentMatch.get(0).projs[0]);
if (matcher.find()) {
int penalty = Integer.parseInt(matcher.group(1));
if (penalty > maxPenalty) {
maxPenalty = penalty;
}
}
} else {
fsrc.add("");
ftrans.add("");
Expand All @@ -289,7 +302,7 @@ public List<NearString> search(String searchText, boolean requiresTranslation, b
PrepareTMXEntry entry = new PrepareTMXEntry();
entry.source = segmenter.glue(sourceLang, sourceLang, fsrc, spaces, brules);
entry.translation = segmenter.glue(sourceLang, targetLang, ftrans, spaces, brules);
processEntry(null, entry, "", NearString.MATCH_SOURCE.TM, false, 0);
processEntry(null, entry, "", NearString.MATCH_SOURCE.TM, false, maxPenalty);
}
}
// fill similarity data only for a result
Expand Down
Loading