Skip to content

Commit

Permalink
Improved Magic scoring slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
n1474335 committed Oct 28, 2019
1 parent 6d138f3 commit 05e65a7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/lib/Magic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,17 @@ class Magic {
let aScore = a.languageScores[0].score,
bScore = b.languageScores[0].score;

// If a recipe results in a file being detected, it receives a relatively good score
if (a.fileType) aScore = 500;
if (b.fileType) bScore = 500;

// If the result is valid UTF8, its score gets boosted (lower being better)
if (a.isUTF8) aScore -= 100;
if (b.isUTF8) bScore -= 100;

// If a recipe results in a file being detected, it receives a relatively good score
if (a.fileType && aScore > 500) aScore = 500;
if (b.fileType && bScore > 500) bScore = 500;

// If the option is marked useful, give it a good score
if (a.useful) aScore = 100;
if (b.useful) bScore = 100;
if (a.useful && aScore > 100) aScore = 100;
if (b.useful && bScore > 100) bScore = 100;

// Shorter recipes are better, so we add the length of the recipe to the score
aScore += a.recipe.length;
Expand Down Expand Up @@ -498,7 +498,7 @@ class Magic {
* Taken from http://wikistats.wmflabs.org/display.php?t=wp
*
* @param {string} code - ISO 639 code
* @returns {string} The full name of the languge
* @returns {string} The full name of the language
*/
static codeToLanguage(code) {
return {
Expand Down

0 comments on commit 05e65a7

Please sign in to comment.