www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit d2e42bda299c2e16fe88a08c0378bf6008146903
parent 8f263d0fd9a9a67eca43b6febd99be9d727ffdbf
Author: Dan Stillman <dstillman@gmail.com>
Date:   Sun, 24 Feb 2013 00:28:43 -0800

Merge pull request #252 from aurimasv/patch-1

Tweaks to duplicate detection
Diffstat:
Mchrome/content/zotero/xpcom/duplicates.js | 19++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/chrome/content/zotero/xpcom/duplicates.js b/chrome/content/zotero/xpcom/duplicates.js @@ -117,8 +117,8 @@ Zotero.Duplicates.prototype._findDuplicates = function () { } str = Zotero.Utilities.removeDiacritics(str) - .replace(/[!-/:-@[-`{-~]/g, ' ') // Convert (ASCII) punctuation to spaces - .replace(/ +/, ' ') // Normalize spaces + .replace(/[ !-/:-@[-`{-~]+/g, ' ') // Convert (ASCII) punctuation to spaces + .trim() .toLowerCase(); return str; @@ -194,7 +194,7 @@ Zotero.Duplicates.prototype._findDuplicates = function () { var isbnCache = {}; if (rows) { for each(var row in rows) { - isbnCache[row.itemID] = row.value; + isbnCache[row.itemID] = row.value.replace(/[^\dX]+/ig, '').toUpperCase(); //ignore formatting } } processRows(); @@ -209,7 +209,7 @@ Zotero.Duplicates.prototype._findDuplicates = function () { var doiCache = {}; if (rows) { for each(var row in rows) { - doiCache[row.itemID] = row.value; + doiCache[row.itemID] = row.value.trim(); } } processRows(); @@ -279,6 +279,7 @@ Zotero.Duplicates.prototype._findDuplicates = function () { } // Check for at least one match on last name + first initial of first name + var aCreatorRows, bCreatorRows; if (typeof creatorRowsCache[a.itemID] != 'undefined') { aCreatorRows = creatorRowsCache[a.itemID]; } @@ -287,7 +288,7 @@ Zotero.Duplicates.prototype._findDuplicates = function () { + "JOIN creators USING (creatorID) " + "JOIN creatorData USING (creatorDataID) " + "WHERE itemID=? ORDER BY orderIndex LIMIT 10"; - var aCreatorRows = Zotero.DB.query(sql, a.itemID); + aCreatorRows = Zotero.DB.query(sql, a.itemID); creatorRowsCache[a.itemID] = aCreatorRows; } @@ -300,12 +301,12 @@ Zotero.Duplicates.prototype._findDuplicates = function () { + "JOIN creators USING (creatorID) " + "JOIN creatorData USING (creatorDataID) " + "WHERE itemID=? ORDER BY orderIndex LIMIT 10"; - var bCreatorRows = Zotero.DB.query(sql, b.itemID); + bCreatorRows = Zotero.DB.query(sql, b.itemID); creatorRowsCache[b.itemID] = bCreatorRows; } // Match if no creators - if (!aCreatorRows && !bCreatorRows.length) { + if (!aCreatorRows && !bCreatorRows) { return 1; } @@ -315,11 +316,11 @@ Zotero.Duplicates.prototype._findDuplicates = function () { for each(var aCreatorRow in aCreatorRows) { var aLastName = normalizeString(aCreatorRow.lastName); - var aFirstInitial = aCreatorRow.fieldMode == 0 ? normalizeString(aCreatorRow.firstName.substr(1)) : false; + var aFirstInitial = aCreatorRow.fieldMode == 0 ? normalizeString(aCreatorRow.firstName).charAt(0) : false; for each(var bCreatorRow in bCreatorRows) { var bLastName = normalizeString(bCreatorRow.lastName); - var bFirstInitial = bCreatorRow.fieldMode == 0 ? normalizeString(bCreatorRow.firstName.substr(1)) : false; + var bFirstInitial = bCreatorRow.fieldMode == 0 ? normalizeString(bCreatorRow.firstName).charAt(0) : false; if (aLastName === bLastName && aFirstInitial === bFirstInitial) { return 1;