From 80b35759b19c0a86da681edcde1e7cd93975ed3c Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Thu, 19 Dec 2024 21:34:26 +0900 Subject: [PATCH] feat: show files used for segmented match in fuzzy match pane Signed-off-by: Hiroshi Miura --- src/org/omegat/core/statistics/FindMatches.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/org/omegat/core/statistics/FindMatches.java b/src/org/omegat/core/statistics/FindMatches.java index 614cb2c8f4..a04ff51316 100644 --- a/src/org/omegat/core/statistics/FindMatches.java +++ b/src/org/omegat/core/statistics/FindMatches.java @@ -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; @@ -299,6 +301,7 @@ public List search(String searchText, boolean requiresTranslation, b Language targetLang = project.getProjectProperties().getTargetLanguage(); List segments = segmenter.segment(sourceLang, srcText, spaces, brules); if (segments.size() > 1) { + Set tmxNames = new HashSet<>(); List fsrc = new ArrayList<>(segments.size()); List ftrans = new ArrayList<>(segments.size()); // multiple segments @@ -310,6 +313,8 @@ public List 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(""); @@ -319,7 +324,7 @@ public List 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