]> git.example.dev Git - binbsis50.git/commitdiff
added a matching rule
authorLuigi Pinca <luigipinca@gmail.com>
Wed, 28 Mar 2012 21:16:30 +0000 (23:16 +0200)
committerLuigi Pinca <luigipinca@gmail.com>
Wed, 28 Mar 2012 21:16:30 +0000 (23:16 +0200)
package.json
server.js

index 2412790dbca9374479300321434275f1c372ad43..81b6a5e3ae47cd3a6bbdd706711cf58a8f95bd5e 100644 (file)
@@ -14,5 +14,5 @@
   "engines": {
     "node": "0.6.x"
   },
-  "version": "0.2.0-4"
+  "version": "0.2.0-7"
 }
\ No newline at end of file
index f38b85cc726eccc3a11d251b6844a9a0545e0fb0..98cd841afb16bdc2afc63501210ca8412bcb6ed2 100644 (file)
--- a/server.js
+++ b/server.js
@@ -127,9 +127,15 @@ var amatch = function(subject, guess, enableartistrules) {
                return true;
        }
        if (enableartistrules) {
-               if (subject.match(/^the /) && 
-                       checkDistance(subject.replace(/^the /, ""), guess, config.threshold)) {
-                       return true;
+               if (subject.match(/^the /)) {
+                       var nothe = subject.replace(/^the /, "");
+                       if (checkDistance(nothe, guess, config.threshold)) {
+                               return true;
+                       }
+                       if (nothe.match(/jimi hendrix experience/) && 
+                               checkDistance(nothe.replace(/ experience/, ""), guess, config.threshold)) {
+                               return true;
+                       }
                }
                splitted = subject.split("&");
                if (splitted.length !== 1) {
@@ -150,11 +156,21 @@ var amatch = function(subject, guess, enableartistrules) {
                        checkDistance(subject.replace(/,/g, ""), guess, config.threshold)) {
                        return true;
                }
-               if (subject.match(/\(.+\)\??(?: \[.+\])?/) && checkDistance(
-                       subject.replace(/\(.+\)\??(?: \[.+\])?/, "").replace(/^ +/, "").replace(/ +$/, ""), 
-                       guess, config.threshold)) {
+               if (subject.match(/ & /) && !subject.match(/\(/) &&
+                       checkDistance(subject.replace(/ & /, " and "), guess, config.threshold)) {
                        return true;
                }
+               if (subject.match(/\(.+\)\??(?: \[.+\])?/)) {
+                       var normalized = subject.replace(/\(.+\)\??(?: \[.+\])?/, "")
+                                                                       .replace(/^ +/, "").replace(/ +$/, "");
+                       if (checkDistance(normalized, guess, config.threshold)) {
+                               return true;
+                       }
+                       if (normalized.match(/ & /) && 
+                               checkDistance(normalized.replace(/ & /, " and "), guess, config.threshold)) {
+                               return true;
+                       }
+               }
                if (subject.match(/, [pP]t\. [0-9]$/) && 
                        checkDistance(subject.replace(/, [pP]t\. [0-9]$/, ""), guess, config.threshold)) {
                        return true;