Skip to content

Commit

Permalink
refactor: fix merge error when split PR#963
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Dec 18, 2024
1 parent f2de1ee commit bf0938f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
10 changes: 7 additions & 3 deletions src/org/omegat/core/statistics/CalcMatchStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.omegat.core.threads.LongProcessThread;
import org.omegat.util.OConsts;
import org.omegat.util.OStrings;
import org.omegat.util.Preferences;
import org.omegat.util.StringUtil;
import org.omegat.util.Token;
import org.omegat.util.gui.TextUtil;
Expand Down Expand Up @@ -107,15 +108,18 @@ public class CalcMatchStatistics extends LongProcessThread {
private final IProject project;

public CalcMatchStatistics(IStatsConsumer callback, boolean perFile) {
this(Core.getProject(), Core.getSegmenter(), callback, perFile);
this(Core.getProject(), Core.getSegmenter(), callback, perFile,
Preferences.getPreferenceDefault(Preferences.EXT_TMX_FUZZY_MATCH_THRESHOLD,
OConsts.FUZZY_MATCH_THRESHOLD));
}

public CalcMatchStatistics(IProject project, Segmenter segmenter, IStatsConsumer callback, boolean perFile) {
public CalcMatchStatistics(IProject project, Segmenter segmenter, IStatsConsumer callback,
boolean perFile, int threshold) {
this.project = project;
this.callback = callback;
this.perFile = perFile;
finder = ThreadLocal.withInitial(
() -> new FindMatches(project, segmenter, OConsts.MAX_NEAR_STRINGS, false, -1));
() -> new FindMatches(project, segmenter, OConsts.MAX_NEAR_STRINGS, false, threshold));
}

@Override
Expand Down
18 changes: 6 additions & 12 deletions test/src/org/omegat/core/statistics/CalcMatchStatisticsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

package org.omegat.core.statistics;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand All @@ -36,7 +35,6 @@

import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import org.omegat.core.Core;
Expand Down Expand Up @@ -67,17 +65,13 @@

public class CalcMatchStatisticsTest {

@BeforeClass
public static void setup() throws IOException {
TestPreferencesInitializer.init();
}

@Test
public void testCalcMatchStatics() throws Exception {
TestProject project = new TestProject(new ProjectPropertiesTest());
IStatsConsumer callback = new TestStatsConsumer();
Segmenter segmenter = new Segmenter(SRX.getDefault());
CalcMatchStatisticsMock calcMatchStatistics = new CalcMatchStatisticsMock(project, segmenter, callback);
CalcMatchStatisticsMock calcMatchStatistics = new CalcMatchStatisticsMock(project, segmenter,
callback, 30);
calcMatchStatistics.start();
try {
calcMatchStatistics.join();
Expand Down Expand Up @@ -130,8 +124,7 @@ public void testCalcMatchStatics() throws Exception {
Assert.assertEquals("5699", result[7][4]);

// change threshold
Preferences.setPreference(Preferences.EXT_TMX_FUZZY_MATCH_THRESHOLD, 70);
calcMatchStatistics = new CalcMatchStatisticsMock(project, segmenter, callback);
calcMatchStatistics = new CalcMatchStatisticsMock(project, segmenter, callback, 70);
calcMatchStatistics.start();
try {
calcMatchStatistics.join();
Expand Down Expand Up @@ -370,8 +363,9 @@ static class CalcMatchStatisticsMock extends CalcMatchStatistics {
private MatchStatCounts result;
private final IStatsConsumer callback;

CalcMatchStatisticsMock(IProject project, Segmenter segmenter, IStatsConsumer callback) {
super(project, segmenter, callback, false);
CalcMatchStatisticsMock(IProject project, Segmenter segmenter, IStatsConsumer callback,
int threshold) {
super(project, segmenter, callback, false, threshold);
this.project = project;
this.callback = callback;
}
Expand Down

0 comments on commit bf0938f

Please sign in to comment.