-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into topic/miurahr/matches/show-files-source-of…
…-segment-matches
- Loading branch information
Showing
14 changed files
with
693 additions
and
270 deletions.
There are no files selected for viewing
347 changes: 185 additions & 162 deletions
347
aligner/src/main/java/org/omegat/gui/align/AlignFilePickerController.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
2008 Alex Buloichik | ||
2012 Thomas Cordonnier, Martin Fleurke | ||
2013 Aaron Madlon-Kay | ||
2024 Hiroshi Miura | ||
Home page: https://www.omegat.org/ | ||
Support center: https://omegat.org/support | ||
|
@@ -32,17 +33,22 @@ | |
import java.util.List; | ||
import java.util.logging.Logger; | ||
|
||
import org.omegat.core.Core; | ||
import org.omegat.core.data.IProject; | ||
import org.omegat.core.data.SourceTextEntry; | ||
import org.omegat.core.events.IStopped; | ||
import org.omegat.core.matching.NearString; | ||
import org.omegat.core.segmentation.Segmenter; | ||
import org.omegat.core.statistics.FindMatches; | ||
import org.omegat.gui.common.EntryInfoSearchThread; | ||
import org.omegat.util.OConsts; | ||
import org.omegat.util.Preferences; | ||
|
||
/** | ||
* Find matches in separate thread then show result in the matches pane. | ||
* Find matches in separate thread then show a result in the matches' pane. | ||
* | ||
* @author Alex Buloichik ([email protected]) | ||
* @author Hiroshi Miura | ||
*/ | ||
public class FindMatchesThread extends EntryInfoSearchThread<List<NearString>> { | ||
private static final Logger LOGGER = Logger.getLogger(FindMatchesThread.class.getName()); | ||
|
@@ -52,9 +58,9 @@ public class FindMatchesThread extends EntryInfoSearchThread<List<NearString>> { | |
|
||
/** | ||
* Entry which is processed currently. | ||
* | ||
* If entry in controller was changed, it means user has moved to another entry, and there is no sense to | ||
* continue. | ||
* <p> | ||
* If entry in controller was changed, it means the user has moved to | ||
* another entry, and there is no sense to continue. | ||
*/ | ||
private final SourceTextEntry processedEntry; | ||
|
||
|
@@ -79,12 +85,26 @@ protected List<NearString> search() throws Exception { | |
long before = System.currentTimeMillis(); | ||
|
||
try { | ||
FindMatches finder = new FindMatches(project, OConsts.MAX_NEAR_STRINGS, true, false); | ||
List<NearString> result = finder.search(processedEntry.getSrcText(), true, true, this::isEntryChanged); | ||
List<NearString> result = finderSearch(project, Core.getSegmenter(), processedEntry.getSrcText(), | ||
this::isEntryChanged, Preferences.getPreferenceDefault( | ||
Preferences.EXT_TMX_FUZZY_MATCH_THRESHOLD, OConsts.FUZZY_MATCH_THRESHOLD)); | ||
LOGGER.finer(() -> "Time for find matches: " + (System.currentTimeMillis() - before)); | ||
return result; | ||
} catch (FindMatches.StoppedException ex) { | ||
throw new EntryChangedException(); | ||
} | ||
} | ||
|
||
/** | ||
* Search matches (static for test purpose). | ||
* @param project OmegaT project. | ||
* @param srcText source text to look for. | ||
* @param isEntryChanged stop and raise StopException when it returns true. | ||
* @return result as a list of NearString. | ||
*/ | ||
protected static List<NearString> finderSearch(IProject project, Segmenter segmenter, String srcText, | ||
IStopped isEntryChanged, int threshold) { | ||
FindMatches finder = new FindMatches(project, segmenter, OConsts.MAX_NEAR_STRINGS, false, threshold); | ||
return finder.search(srcText, true, isEntryChanged); | ||
} | ||
} |
Oops, something went wrong.