]> git.example.dev Git - binbsis50.git/commitdiff
improved artist's name matching
authorLuigi Pinca <luigipinca@gmail.com>
Sun, 27 Oct 2013 11:50:54 +0000 (12:50 +0100)
committerLuigi Pinca <luigipinca@gmail.com>
Sun, 27 Oct 2013 11:50:54 +0000 (12:50 +0100)
lib/match.js
package.json

index 36c1776c9428c565f10078c5ea9c79b061991c64..7dddce4786fb2cbe8f840caa1337b85457e16ca1 100644 (file)
@@ -82,29 +82,44 @@ module.exports = function(subject, guess, enableartistrules) {
   }
 
   if (enableartistrules) {
-    // Ignore "the" at the beginning of artist name
-    if (/^the /.test(subject)) {
-      var nothe = subject.replace(/^the /, '');
-      if (checkDistance(nothe, guess, threshold)) {
-        return true;
-      }
-      if (/jimi hendrix experience/.test(nothe) && 
-        checkDistance(nothe.replace(/ experience/, ''), guess, threshold)) {
-        return true;
-      }
-    }
     // Split artist name on " & " and ", " (artist name can be composed by more names)
-    var splitted = subject.split(/ & |, /);
-    if (splitted.length !== 1) {
-      for (var i=0; i<splitted.length; i++) {
-        if (checkDistance(splitted[i], guess, threshold)) {
+    var splits = subject.split(/ & |, /)
+      , multipleartists = splits.length !== 1;
+    for (var i = 0; i < splits.length; i++) {
+      var artist = splits[i];
+      if (multipleartists) {
+        if (checkDistance(artist, guess, threshold)) {
+          return true;
+        }
+        if (/\./.test(artist) &&
+          checkDistance(artist.replace(/\./g, ''), guess, threshold)) {
+          return true;
+        }
+      }
+      // Ignore "the" at the beginning of artist name
+      if (/^the /.test(artist)) {
+        var nothe = artist.replace(/^the /, '');
+        if (checkDistance(nothe, guess, threshold)) {
+          return true;
+        }
+        if (/\./.test(nothe) &&
+          checkDistance(nothe.replace(/\./g, ''), guess, threshold)) {
           return true;
         }
-        if (/^the /.test(splitted[i]) && 
-          checkDistance(splitted[i].replace(/^the /, ''), guess, threshold)) {
+        if (/jimi hendrix experience/.test(nothe) &&
+          checkDistance(nothe.replace(/ experience/, ''), guess, threshold)) {
           return true;
         }
       }
+      if (guess === 'ccr' && artist === 'creedence clearwater revival') {
+        return true;
+      }
+      if (guess === 'elo' && artist === 'electric light orchestra') {
+        return true;
+      }
+      if (guess === 'omd' && artist === 'orchestral manoeuvres in the dark') {
+        return true;
+      }
     }
   }
   else {
index 7cbe49016f8d4f48c7d18b693718e9f3aade9242..337375181051f4eb9f0caa089b348d2ef6ddf67a 100644 (file)
@@ -29,5 +29,5 @@
     "start": "node app.js"
   },
   "subdomain": "binb",
-  "version": "0.3.6-10"
+  "version": "0.3.6-11"
 }