Permalink
Browse files

Prune matches with scores that adjusted to zero. Introduces 'NO_RESUL…

…TS_HISTOGRAM_DECREASED' and 'SINGLE_GOOD_MATCH_HISTOGRAM_DECREASED'
  • Loading branch information...
1 parent 8d0ae74 commit 9d00e6e236a8b3bfa77da274b801b6f3b83839b3 @jhurliman committed Feb 26, 2012
Showing with 15 additions and 4 deletions.
  1. +15 −4 controllers/fingerprinter.js
View
19 controllers/fingerprinter.js
@@ -17,6 +17,7 @@ exports.decodeCodeString = decodeCodeString;
exports.cutFPLength = cutFPLength;
exports.getCodesToTimes = getCodesToTimes;
exports.bestMatchForQuery = bestMatchForQuery;
+exports.getTrackMetadata = getTrackMetadata;
exports.ingest = ingest;
exports.SECONDS_TO_TIMESTAMP = SECONDS_TO_TIMESTAMP;
exports.MATCH_SLOP = MATCH_SLOP;
@@ -138,18 +139,28 @@ function bestMatchForQuery(fp, threshold, callback) {
// Compute more accurate scores for each track by taking time offsets into
// account
+ var newMatches = [];
+ var newCount = 0;
for (var i = 0; i < matches.length; i++) {
- matches[i].ascore = getActualScore(fp, matches[i], threshold,
- MATCH_SLOP);
+ var match = matches[i];
+ match.ascore = getActualScore(fp, match, threshold, MATCH_SLOP);
+ if (match.ascore)
+ newMatches[newCount++] = match;
+ }
+ matches = newMatches;
+
+ if (!matches.length) {
+ log.debug('No matched tracks after score adjustment');
+ return callback(null, { status: 'NO_RESULTS_HISTOGRAM_DECREASED' });
}
// If we only had one track match, just use the threshold to determine if
// the match is good enough
if (matches.length === 1) {
if (matches[0].ascore / fp.codes.length >= MIN_MATCH_PERCENT) {
// Fetch metadata for the single match
- return getTrackMetadata(matches[0], matches, 'SINGLE_GOOD_MATCH',
- callback);
+ return getTrackMetadata(matches[0], matches,
+ 'SINGLE_GOOD_MATCH_HISTOGRAM_DECREASED', callback);
} else {
log.debug('Single bad match with actual score ' + matches[0].ascore +
'/' + fp.codes.length);

0 comments on commit 9d00e6e

Please sign in to comment.