Skip to content

Commit

Permalink
Apply max penalty for sub-segment match
Browse files Browse the repository at this point in the history
  • Loading branch information
t-cordonnier committed Dec 2, 2024
1 parent fb1fd6b commit a858d4e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/org/omegat/core/statistics/FindMatches.java
Original file line number Diff line number Diff line change
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 Down

0 comments on commit a858d4e

Please sign in to comment.