Skip to content
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

Scoring filter of 100 in first-recording-search.php #32

Open
hawkwynd opened this issue Sep 18, 2019 · 0 comments
Open

Scoring filter of 100 in first-recording-search.php #32

hawkwynd opened this issue Sep 18, 2019 · 0 comments

Comments

@hawkwynd
Copy link

hawkwynd commented Sep 18, 2019

I've found that on many searches, results scoring < 100 actually contain the correct release I am looking for. Here's a snippet of the code which I am currently using to obtain the first-known-release of a recording by artist.

foreach($recordings as $recording){
        // If recording score is lower than what we have now, we want 100, but have found
        // 99 is acceptable in most cases to properly match on the original first recording
        // for this release.
         if (null != $lastScore && $lastScore < 99) {
            break;
         }      
         
        $lastScore        = $recording->getScore();
        $releaseDates     = $recording->getReleaseDates();
        $oldestReleaseKey = key($releaseDates);
        
        // Only compare the year of the release so we format the date field to just the year
        if( $releaseDates[$oldestReleaseKey]->format('Y') <= $firstRecording['releaseDate']->format('Y')){

            $firstRecording = array(
                'query'       => $args,
                'release'     => $recording->releases[$oldestReleaseKey],
                'releaseDate' => $recording->releases[$oldestReleaseKey]->getReleaseDate(),
                'release-count' => count($recording->releases),
                'recording'   => $recording,            
                'artist'      => $recording->getArtist(),
                'recordingId' => $recording->getId(),
                'trackLength' => $recording->getLength(),
                'execution'   => new stdClass(), // used for debugging 
                );
                
        }
    }

While, it's not really an issue, I thought it best to share this here. For some reason, I have found that many scores of 99 are being returned with the correct results, while scores of 100 have sometimes been returning incorrect results. By lowering the score threshold to 99, it seems to be giving me results much closer to the actual "First" recording.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant