Fix inconsistent SubstringFields metric behaviour

This commit is contained in:
Reinhard Pointner 2016-08-23 00:51:47 +08:00
parent 4333193b98
commit bdc81b3501
1 changed files with 4 additions and 1 deletions

View File

@ -208,10 +208,13 @@ public enum EpisodeMetrics implements SimilarityMetric {
return stream(objects).map(EpisodeMetrics::normalizeObject).toArray(String[]::new);
}
protected static final int MAX_FIELDS = 5;
protected Object[] fields(Object object) {
if (object instanceof Episode) {
Episode e = (Episode) object;
return StreamEx.of(e.getSeriesName(), e.getTitle()).append(e.getSeriesNames()).filter(Objects::nonNull).map(Normalization::removeTrailingBrackets).distinct().limit(5).toArray();
Object[] names = StreamEx.of(e.getSeriesName(), e.getTitle()).append(e.getSeriesNames()).filter(Objects::nonNull).map(Normalization::removeTrailingBrackets).distinct().limit(MAX_FIELDS).toArray();
return copyOf(names, MAX_FIELDS);
}
if (object instanceof File) {