mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-05 00:45:06 -05:00
* fix series detection regression issues
This commit is contained in:
parent
2fa6be847e
commit
173d5e95c6
@ -826,7 +826,7 @@ public class MediaDetection {
|
||||
|
||||
|
||||
public HighPerformanceMatcher(int maxStartIndex) {
|
||||
super(collator, maxStartIndex);
|
||||
super(collator, maxStartIndex, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,11 +24,13 @@ public class CommonSequenceMatcher {
|
||||
|
||||
protected final Collator collator;
|
||||
protected final int commonSequenceMaxStartIndex;
|
||||
protected final boolean returnFirstMatch;
|
||||
|
||||
|
||||
public CommonSequenceMatcher(Collator collator, int commonSequenceMaxStartIndex) {
|
||||
public CommonSequenceMatcher(Collator collator, int commonSequenceMaxStartIndex, boolean returnFirstMatch) {
|
||||
this.collator = collator;
|
||||
this.commonSequenceMaxStartIndex = commonSequenceMaxStartIndex;
|
||||
this.returnFirstMatch = returnFirstMatch;
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +50,7 @@ public class CommonSequenceMatcher {
|
||||
common = words;
|
||||
} else {
|
||||
// find common sequence
|
||||
common = firstCommonSequence(common, words, commonSequenceMaxStartIndex);
|
||||
common = firstCommonSequence(common, words, commonSequenceMaxStartIndex, returnFirstMatch);
|
||||
|
||||
if (common == null) {
|
||||
// no common sequence
|
||||
@ -96,7 +98,7 @@ public class CommonSequenceMatcher {
|
||||
}
|
||||
|
||||
|
||||
protected <E extends Comparable<E>> E[] firstCommonSequence(E[] seq1, E[] seq2, int maxStartIndex) {
|
||||
protected <E extends Comparable<E>> E[] firstCommonSequence(E[] seq1, E[] seq2, int maxStartIndex, boolean returnFirstMatch) {
|
||||
E[] matchSeq = null;
|
||||
for (int i = 0; i < seq1.length && i <= maxStartIndex; i++) {
|
||||
for (int j = 0; j < seq2.length && j <= maxStartIndex; j++) {
|
||||
@ -111,6 +113,11 @@ public class CommonSequenceMatcher {
|
||||
// check if a common sequence was found
|
||||
if (len > (matchSeq == null ? 0 : matchSeq.length)) {
|
||||
matchSeq = copyOfRange(seq1, i, i + len);
|
||||
|
||||
// look for first match
|
||||
if (returnFirstMatch) {
|
||||
return matchSeq;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import java.util.Locale;
|
||||
|
||||
public class SequenceMatchSimilarity implements SimilarityMetric {
|
||||
|
||||
private final CommonSequenceMatcher commonSequenceMatcher = new CommonSequenceMatcher(getLenientCollator(Locale.ROOT), 10);
|
||||
private final CommonSequenceMatcher commonSequenceMatcher = new CommonSequenceMatcher(getLenientCollator(Locale.ROOT), 10, false);
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -46,7 +46,7 @@ public class SeriesNameMatcher {
|
||||
|
||||
|
||||
public SeriesNameMatcher(Locale locale) {
|
||||
commonSequenceMatcher = new CommonSequenceMatcher(getLenientCollator(locale), 3) {
|
||||
commonSequenceMatcher = new CommonSequenceMatcher(getLenientCollator(locale), 3, true) {
|
||||
|
||||
@Override
|
||||
protected CollationKey[] split(String sequence) {
|
||||
|
Loading…
Reference in New Issue
Block a user