-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGS#1251] FindMatches always search separate segment match without penalty: add regression test, fix it, make configurable, show where comes from in FuzzyMatch pane, and refactor #963
Draft
miurahr
wants to merge
19
commits into
master
Choose a base branch
from
topic/miurahr/matches/fix-separate-segmented
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
711f747
[BUGS#1251] feat: add regression test
miurahr f049239
[BUGS#1251] fix and refactor: FindMatches
miurahr 932986b
style: copyright header
miurahr 52c2ac5
Apply suggestions from code review
miurahr c204ce1
docs: adjust a javadoc by reflecting review feedbacks
miurahr 168a14f
fix: put @Deprecated(since = "6.1.0")
miurahr 29a8751
style: javadoc and line length
miurahr 629b414
style: fix typo in javadoc
miurahr 8a80997
feat: add a case to test FindMatches
miurahr 375ae46
feat: Add acceptance test of Fuzzy matches pane
miurahr 0a00820
[BUGS#1248] fix: segmented search respect penalty
miurahr c96855e
fix: test expectation
miurahr 8b1556f
feat/docs: preference for paragraph from segmented tmx
miurahr 91a7812
Update src/org/omegat/core/statistics/FindMatches.java
miurahr 6cb98b9
Merge branch 'master' into topic/miurahr/matches/fix-separate-segmented
miurahr f850d1b
fix: test expectation
miurahr 55910ac
feat: introduce matchSource match template variable
miurahr c1bec8b
style: NearString, MatchesVarExpansion and FindMatchesThreadTest
miurahr 0878d1b
feat: gather all the combined files
miurahr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -49,50 +49,95 @@ | |||||
*/ | ||||||
public class NearString { | ||||||
public enum MATCH_SOURCE { | ||||||
MEMORY, TM, FILES | ||||||
}; | ||||||
/** From project memory */ | ||||||
MEMORY, | ||||||
/** From external TM in project tm/ folder */ | ||||||
TM, | ||||||
/** From files */ | ||||||
FILES, | ||||||
/** From sub-segmented match */ | ||||||
TM_SUBSEG; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
no need semicolon |
||||||
} | ||||||
|
||||||
public enum SORT_KEY { | ||||||
SCORE, SCORE_NO_STEM, ADJUSTED_SCORE | ||||||
/** normal score */ | ||||||
SCORE, | ||||||
/** score without stemming */ | ||||||
SCORE_NO_STEM, | ||||||
/** adjusted score */ | ||||||
ADJUSTED_SCORE | ||||||
} | ||||||
|
||||||
public NearString(EntryKey key, ITMXEntry entry, MATCH_SOURCE comesFrom, boolean fuzzyMark, | ||||||
Scores scores, byte[] nearData, String projName) { | ||||||
this(key, entry.getSourceText(), entry.getTranslationText(), comesFrom, fuzzyMark, scores, | ||||||
nearData, projName, entry.getCreator(), entry.getCreationDate(), entry.getChanger(), | ||||||
/** | ||||||
* Constructor. | ||||||
* | ||||||
* @param key | ||||||
* entry key | ||||||
* @param entry | ||||||
* the TMX entry that has source text, translation text, creator, | ||||||
* creation date, changer, change date and properties. | ||||||
* @param comesFrom | ||||||
* origin | ||||||
* @param fuzzyMark | ||||||
* fuzzy or not | ||||||
* @param scores | ||||||
* score values | ||||||
* @param nearData | ||||||
* similarity data. | ||||||
* @param projName | ||||||
* project name. | ||||||
*/ | ||||||
public NearString(EntryKey key, ITMXEntry entry, MATCH_SOURCE comesFrom, boolean fuzzyMark, Scores scores, | ||||||
byte[] nearData, String projName) { | ||||||
this(key, entry.getSourceText(), entry.getTranslationText(), comesFrom, fuzzyMark, scores, nearData, | ||||||
projName, entry.getCreator(), entry.getCreationDate(), entry.getChanger(), | ||||||
entry.getChangeDate(), entry.getProperties()); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Constructor, backward compatible. | ||||||
* @param key entry key | ||||||
* @param source source text | ||||||
* @param translation translation text | ||||||
* @param comesFrom origin | ||||||
* @param fuzzyMark fuzzy or not | ||||||
* | ||||||
* @param key | ||||||
* entry key | ||||||
* @param source | ||||||
* source text | ||||||
* @param translation | ||||||
* translation text | ||||||
* @param comesFrom | ||||||
* origin | ||||||
* @param fuzzyMark | ||||||
* fuzzy or not | ||||||
* @param nearScore | ||||||
* @param nearScoreNoStem | ||||||
* @param adjustedScore | ||||||
* @param nearData similarity data. | ||||||
* @param projName project name. | ||||||
* @param creator creator name | ||||||
* @param creationDate creation date | ||||||
* @param changer changer name | ||||||
* @param changedDate changer date | ||||||
* @param props properties of entry. | ||||||
* @param nearData | ||||||
* similarity data. | ||||||
* @param projName | ||||||
* project name. | ||||||
* @param creator | ||||||
* creator name | ||||||
* @param creationDate | ||||||
* creation date | ||||||
* @param changer | ||||||
* changer name | ||||||
* @param changedDate | ||||||
* changer date | ||||||
* @param props | ||||||
* properties of entry. | ||||||
*/ | ||||||
@Deprecated | ||||||
public NearString(EntryKey key, String source, String translation, MATCH_SOURCE comesFrom, | ||||||
boolean fuzzyMark, int nearScore, int nearScoreNoStem, int adjustedScore, | ||||||
byte[] nearData, String projName, String creator, long creationDate, | ||||||
String changer, long changedDate, List<TMXProp> props) { | ||||||
this(key, source, translation, comesFrom, fuzzyMark, new Scores(nearScore, nearScoreNoStem, | ||||||
adjustedScore), nearData, projName, creator, creationDate, changer, changedDate, props); | ||||||
boolean fuzzyMark, int nearScore, int nearScoreNoStem, int adjustedScore, byte[] nearData, | ||||||
String projName, String creator, long creationDate, String changer, long changedDate, | ||||||
List<TMXProp> props) { | ||||||
this(key, source, translation, comesFrom, fuzzyMark, | ||||||
new Scores(nearScore, nearScoreNoStem, adjustedScore), nearData, projName, creator, | ||||||
creationDate, changer, changedDate, props); | ||||||
} | ||||||
|
||||||
private NearString(EntryKey key, String source, String translation, MATCH_SOURCE comesFrom, | ||||||
boolean fuzzyMark, Scores scores, byte[] nearData, String projName, String creator, | ||||||
long creationDate, String changer, long changedDate, List<TMXProp> props) { | ||||||
boolean fuzzyMark, Scores scores, byte[] nearData, String projName, String creator, | ||||||
long creationDate, String changer, long changedDate, List<TMXProp> props) { | ||||||
this.key = key; | ||||||
this.source = source; | ||||||
this.translation = translation; | ||||||
|
@@ -110,18 +155,27 @@ private NearString(EntryKey key, String source, String translation, MATCH_SOURCE | |||||
|
||||||
/** | ||||||
* Merge NearString object. | ||||||
* @param ns NearString to merge. | ||||||
* @param key entry key. | ||||||
* @param entry TMXEntry entry | ||||||
* @param comesFrom origin | ||||||
* @param fuzzyMark fuzzy or not | ||||||
* @param scores similarity score | ||||||
* @param nearData similarity data | ||||||
* @param projName project name | ||||||
* | ||||||
* @param ns | ||||||
* NearString to merge. | ||||||
* @param key | ||||||
* entry key. | ||||||
* @param entry | ||||||
* TMXEntry entry | ||||||
* @param comesFrom | ||||||
* origin | ||||||
* @param fuzzyMark | ||||||
* fuzzy or not | ||||||
* @param scores | ||||||
* similarity score | ||||||
* @param nearData | ||||||
* similarity data | ||||||
* @param projName | ||||||
* project name | ||||||
* @return NearString merged. | ||||||
*/ | ||||||
public static NearString merge(NearString ns, EntryKey key, ITMXEntry entry, MATCH_SOURCE comesFrom, | ||||||
boolean fuzzyMark, Scores scores, byte[] nearData, String projName) { | ||||||
boolean fuzzyMark, Scores scores, byte[] nearData, String projName) { | ||||||
|
||||||
List<String> projs = new ArrayList<>(); | ||||||
List<Scores> mergedScores = new ArrayList<>(); | ||||||
|
@@ -134,9 +188,8 @@ public static NearString merge(NearString ns, EntryKey key, ITMXEntry entry, MAT | |||||
projs.add(0, projName); | ||||||
mergedScores.add(0, merged.scores[0]); | ||||||
} else { | ||||||
merged = new NearString(ns.key, ns.source, ns.translation, ns.comesFrom, ns.fuzzyMark, | ||||||
scores, ns.attr, null, ns.creator, ns.creationDate, ns.changer, | ||||||
ns.changedDate, ns.props); | ||||||
merged = new NearString(ns.key, ns.source, ns.translation, ns.comesFrom, ns.fuzzyMark, scores, | ||||||
ns.attr, null, ns.creator, ns.creationDate, ns.changer, ns.changedDate, ns.props); | ||||||
projs.add(projName); | ||||||
mergedScores.add(merged.scores[0]); | ||||||
} | ||||||
|
@@ -146,10 +199,11 @@ public static NearString merge(NearString ns, EntryKey key, ITMXEntry entry, MAT | |||||
} | ||||||
|
||||||
@Deprecated | ||||||
public static NearString merge(NearString ns, final EntryKey key, final String source, final String translation, | ||||||
MATCH_SOURCE comesFrom, final boolean fuzzyMark, final int nearScore, final int nearScoreNoStem, | ||||||
final int adjustedScore, final byte[] nearData, final String projName, final String creator, | ||||||
final long creationDate, final String changer, final long changedDate, final List<TMXProp> props) { | ||||||
public static NearString merge(NearString ns, final EntryKey key, final String source, | ||||||
final String translation, MATCH_SOURCE comesFrom, final boolean fuzzyMark, final int nearScore, | ||||||
final int nearScoreNoStem, final int adjustedScore, final byte[] nearData, final String projName, | ||||||
final String creator, final long creationDate, final String changer, final long changedDate, | ||||||
final List<TMXProp> props) { | ||||||
|
||||||
List<String> projs = new ArrayList<>(); | ||||||
List<Scores> mergedScores = new ArrayList<>(); | ||||||
|
@@ -159,7 +213,8 @@ public static NearString merge(NearString ns, final EntryKey key, final String s | |||||
NearString merged; | ||||||
if (nearScore > ns.scores[0].score) { | ||||||
merged = new NearString(key, source, translation, comesFrom, fuzzyMark, nearScore, | ||||||
nearScoreNoStem, adjustedScore, nearData, null, creator, creationDate, changer, changedDate, props); | ||||||
nearScoreNoStem, adjustedScore, nearData, null, creator, creationDate, changer, | ||||||
changedDate, props); | ||||||
projs.add(0, projName); | ||||||
mergedScores.add(0, merged.scores[0]); | ||||||
} else { | ||||||
|
@@ -204,11 +259,17 @@ public static class Scores { | |||||
public final int scoreNoStem; | ||||||
/** adjusted similarity score for match including all tokens */ | ||||||
public final int adjustedScore; | ||||||
public final int penalty; | ||||||
|
||||||
public Scores(int score, int scoreNoStem, int adjustedScore) { | ||||||
this(score, scoreNoStem, adjustedScore, 0); | ||||||
} | ||||||
|
||||||
public Scores(int score, int scoreNoStem, int adjustedScore, int penalty) { | ||||||
this.score = score; | ||||||
this.scoreNoStem = scoreNoStem; | ||||||
this.adjustedScore = adjustedScore; | ||||||
this.penalty = penalty; | ||||||
} | ||||||
|
||||||
public String toString() { | ||||||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kazephil we need your review in the 3 documentation files below. Thank you in advance.