From: Luigi Pinca Date: Wed, 28 Mar 2012 21:16:30 +0000 (+0200) Subject: added a matching rule X-Git-Url: https://git.saalbach.dev/?a=commitdiff_plain;h=27faef9f31bae5ccbca1bc2c224ee5d6a25b03f3;p=binbsis50.git added a matching rule --- diff --git a/package.json b/package.json index 2412790..81b6a5e 100644 --- a/package.json +++ b/package.json @@ -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 diff --git a/server.js b/server.js index f38b85c..98cd841 100644 --- 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;