Skip to content

Commit

Permalink
feat: show files used for segmented match in fuzzy match pane
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Dec 19, 2024
1 parent c9b91fe commit 80b3575
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/org/omegat/core/statistics/FindMatches.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -299,6 +301,7 @@ public List<NearString> search(String searchText, boolean requiresTranslation, b
Language targetLang = project.getProjectProperties().getTargetLanguage();
List<String> segments = segmenter.segment(sourceLang, srcText, spaces, brules);
if (segments.size() > 1) {
Set<String> tmxNames = new HashSet<>();
List<String> fsrc = new ArrayList<>(segments.size());
List<String> ftrans = new ArrayList<>(segments.size());
// multiple segments
Expand All @@ -310,6 +313,8 @@ 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);
segmentMatch.stream().filter(match -> !match.projs[0].isEmpty())
.map(match -> match.projs[0]).forEach(tmxNames::add);
} else {
fsrc.add("");
ftrans.add("");
Expand All @@ -319,7 +324,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, String.join(",", tmxNames), NearString.MATCH_SOURCE.TM, false, 0);
}
}
// fill similarity data only for a result
Expand Down

0 comments on commit 80b3575

Please sign in to comment.