{ "id": "t2peFUn5eWavYRnf", "name": "Debug Fuzzy Match JS", "nodes": [ { "id": "Manual", "name": "Manual", "parameters": {}, "position": [ 220, 140 ], "type": "n8n-nodes-base.manualTrigger", "typeVersion": 1 }, { "id": "Code", "name": "Code", "parameters": { "jsCode": "\nconst seriesList = [\n {\"series_name\":\"The Lost Web-Shooter\",\"author\":\"Marvel Press Book Group\"},\n {\"series_name\":\"The Well of Ascension [B002V5GLQ4]\",\"author\":\"Brandon Sanderson\"},\n {\"series_name\":\"The Stormlight Archive\",\"author\":\"Terry Brooks\"},\n {\"series_name\":\"Black Summoner\",\"author\":null},\n {\"series_name\":\"Classroom of the Elite\",\"author\":null},\n {\"series_name\":\"How a Realist Hero Rebuilt the Kingdom\",\"author\":null},\n {\"series_name\":\"Is It Wrong to Try to Pick Up Girls in a Dungeon\",\"author\":null},\n {\"series_name\":\"Min-Maxing My TRPG Build in Another World\",\"author\":null},\n {\"series_name\":\"Monogatari\",\"author\":null},\n {\"series_name\":\"Musashi\",\"author\":null},\n {\"series_name\":\"Mushoku Tensei\",\"author\":null},\n {\"series_name\":\"My Quiet Blacksmith Life in Another World\",\"author\":null},\n {\"series_name\":\"Neon Genesis Evangelion ANIMA\",\"author\":null},\n {\"series_name\":\"Overlord\",\"author\":null},\n {\"series_name\":\"Paul Dateh\",\"author\":null},\n {\"series_name\":\"Rascal Does Not Dream of\",\"author\":null},\n {\"series_name\":\"Reborn as a Space Mercenary\",\"author\":null},\n {\"series_name\":\"She Professed Herself Pupil of the Wise Man\",\"author\":null},\n {\"series_name\":\"Spice and Wolf\",\"author\":null},\n {\"series_name\":\"Sword Art Online\",\"author\":null},\n {\"series_name\":\"The Executioner and Her Way of Life\",\"author\":null},\n {\"series_name\":\"The Faraway Paladin\",\"author\":null},\n {\"series_name\":\"The NPCs in this Village Sim Game Must Be Real!\",\"author\":null},\n {\"series_name\":\"The Rising of the Shield Hero\",\"author\":null},\n {\"series_name\":\"The Saga of Tanya the Evil\",\"author\":null},\n {\"series_name\":\"The Saint's Magic Power is Omnipotent\",\"author\":null},\n {\"series_name\":\"The Tweleve Kingdoms\",\"author\":null},\n {\"series_name\":\"Toradora!\",\"author\":null},\n {\"series_name\":\"Vampire Hunter D\",\"author\":null},\n {\"series_name\":\"Witch and Mercenary\",\"author\":null},\n {\"series_name\":\"Chaos Seeds\",\"author\":\"Aleron Kong\"},\n {\"series_name\":\"The Stolen Hours\",\"author\":\"Allen Eskens\"},\n {\"series_name\":\"The Berry Pickers\",\"author\":\"Amanda Peters\"},\n {\"series_name\":\"Standalone\",\"author\":\"V. E. Schwab\"},\n {\"series_name\":\"Azarinth Healer\",\"author\":\"Andrea Parsneau\"},\n {\"series_name\":\"Empires of EVE\",\"author\":\"Andrew Groen\"},\n {\"series_name\":\"Sufficiently Advanced Magic\",\"author\":\"Andrew Rowe\"},\n {\"series_name\":\"The Witcher\",\"author\":\"Andrzej Sapkowski\"},\n {\"series_name\":\"Dear Edward\",\"author\":\"Ann Napolitano\"},\n {\"series_name\":\"Workout\",\"author\":\"Aptiv\"},\n {\"series_name\":\"Sherlock Holmes\",\"author\":\"Arthur Conan Doyle\"},\n {\"series_name\":\"Being Mortal\",\"author\":\"Atul Gawande\"},\n {\"series_name\":\"Peril\",\"author\":\"Bob Woodward\"},\n {\"series_name\":\"Cosmere\",\"author\":\"Brandon Sanderson\"},\n {\"series_name\":\"Skyward\",\"author\":\"Brandon Sanderson\"},\n {\"series_name\":\"Lightbringer\",\"author\":\"Brent Weeks\"},\n {\"series_name\":\"Night Angel\",\"author\":\"Brent Weeks\"},\n {\"series_name\":\"The Path of Ascension\",\"author\":\"J.S. Arquin\"},\n {\"series_name\":\"A Boy and His Dog at the End of the World\",\"author\":\"C. A. Fletcher\"},\n {\"series_name\":\"Hell Difficulty Tutorial\",\"author\":\"Cerim\"},\n {\"series_name\":\"The Hitchhiker's Guide to the Galaxy\",\"author\":\"Erik Larson\"},\n {\"series_name\":\"Firefly\",\"author\":\"Firefly Series\"},\n {\"series_name\":\"The Lord of the Rings\",\"author\":\"J. R. R. Tolkein\"},\n {\"series_name\":\"Age of Bronze\",\"author\":\"Jez Cajiao\"},\n {\"series_name\":\"Beware of Chicken\",\"author\":\"Casualfarmer\"},\n {\"series_name\":\"The Cuckoo's Egg\",\"author\":\"Cliff Stoll\"},\n {\"series_name\":\"Verity\",\"author\":\"Colleen Hoover\"},\n {\"series_name\":\"Expeditionary Force\",\"author\":\"Craig Alanson\"},\n {\"series_name\":\"Hyperion Cantos\",\"author\":\"Dan Simmons\"},\n {\"series_name\":\"Millennium\",\"author\":\"Stieg Larsson\"},\n {\"series_name\":\"The House at the End of the World\",\"author\":\"Dean Koontz\"},\n {\"series_name\":\"Bobiverse\",\"author\":\"Dennis E. Taylor\"},\n {\"series_name\":\"Member of the Family\",\"author\":\"Dianne Lake\"},\n {\"series_name\":\"Pendergast\",\"author\":\"Douglas Preston\"},\n {\"series_name\":\"The Chronicles of Draven\",\"author\":\"Draith\"},\n {\"series_name\":\"Dungeon Exploiters\",\"author\":\"Dustin Tigner\"},\n {\"series_name\":\"The Cycle of Arawn\",\"author\":\"Edward W Robertson\"},\n {\"series_name\":\"Great Big Beautiful Life\",\"author\":\"Emily Henry\"},\n {\"series_name\":\"The Best Laid Plans\",\"author\":\"Eric Ugland\"},\n {\"series_name\":\"The Splendid and the Vile\",\"author\":\"Erik Larson\"},\n {\"series_name\":\"The Firefly Series\",\"author\":\"Firefly Series\"},\n {\"series_name\":\"Dune Chronicles\",\"author\":\"Frank Herbert\"},\n {\"series_name\":\"1984\",\"author\":\"George Orwell\"},\n {\"series_name\":\"A Song of Ice and Fire\",\"author\":\"George R. R. Martin\"},\n {\"series_name\":\"Myron Bolitar\",\"author\":\"Harlan Coben\"},\n {\"series_name\":\"Wool\",\"author\":\"Hugh Howey\"},\n {\"series_name\":\"Bonnie\",\"author\":\"Iris Johansen\"},\n {\"series_name\":\"Guild Master\",\"author\":\"Ivan Kal\"},\n {\"series_name\":\"Mark of the Fool\",\"author\":\"J M Clarke\"},\n {\"series_name\":\"Black Ocean Astral Prime\",\"author\":\"J S Morin\"},\n {\"series_name\":\"Black Ocean: Mirth & Mayhem Complete Collection: Missions 1-16 [B0CQ343MNR]\",\"author\":\"J S Morin\"},\n {\"series_name\":\"Galaxy Outlaws\",\"author\":\"J S Morin\"},\n {\"series_name\":\"Mirth & Mayhem\",\"author\":\"J S Morin\"},\n {\"series_name\":\"Twinborn Chronicles\",\"author\":\"J S Morin\"},\n {\"series_name\":\"Quantum Cultivation\",\"author\":\"Jace Kang\"},\n {\"series_name\":\"James Reece\",\"author\":\"Jack Carr\"},\n {\"series_name\":\"The Terminal List\",\"author\":\"Jack Carr\"},\n {\"series_name\":\"Jake Elwood Military Sci-Fi\",\"author\":\"Jake Elwood\"},\n {\"series_name\":\"Rogue\",\"author\":\"Jake Elwood\"},\n {\"series_name\":\"The President's Daughter\",\"author\":\"James Petterson\"},\n {\"series_name\":\"Small Great Things\",\"author\":\"Jodi Picoult\"},\n {\"series_name\":\"IQ\",\"author\":\"Joe Ide\"},\n {\"series_name\":\"Stand Alone\",\"author\":\"John Grisham\"},\n {\"series_name\":\"Jonathan Kellerman\",\"author\":\"Jonathan Kellerman\"},\n {\"series_name\":\"The Omega Series\",\"author\":\"Joshua Dalzelle\"},\n {\"series_name\":\"Electric Angel\",\"author\":\"Plum Parrot\"},\n {\"series_name\":\"King's Dark Tidings\",\"author\":\"Kel Kade\"},\n {\"series_name\":\"Shroud of Prophecy\",\"author\":\"Kel Kade\"},\n {\"series_name\":\"The Missing\",\"author\":\"Kiersten Modglin\"},\n {\"series_name\":\"The Last Thing He Told Me\",\"author\":\"Laura Dave\"},\n {\"series_name\":\"Mr. Texas\",\"author\":\"Lawrence Wright\"},\n {\"series_name\":\"Interview with the Robot\",\"author\":\"Lee Bacon\"},\n {\"series_name\":\"Jack Reacher\",\"author\":\"Lee Child\"},\n {\"series_name\":\"A Fallen Empire\",\"author\":\"Lindsay Buroker\"},\n {\"series_name\":\"Oath and Honor\",\"author\":\"Liz Cheney\"},\n {\"series_name\":\"Gray Man\",\"author\":\"Mark Greaney\"},\n {\"series_name\":\"The Eye of the Bedlam Bride\",\"author\":\"Matt Dinniman\"},\n {\"series_name\":\"Romney\",\"author\":\"McKay Coppins\"},\n {\"series_name\":\"Ballard and Bosch\",\"author\":\"Michael Connelly\"},\n {\"series_name\":\"Harry Bosch\",\"author\":\"Michael Connelly\"},\n {\"series_name\":\"Bosch and Ballard\",\"author\":\"Michael Connelly\"},\n {\"series_name\":\"Nightshade\",\"author\":\"Michael Connelly\"},\n {\"series_name\":\"The Born Series\",\"author\":\"Michael Livingston\"},\n {\"series_name\":\"Caffeine\",\"author\":\"Michael Pollan\"},\n {\"series_name\":\"Sociopath\",\"author\":\"Patric Gagne Ph.D\"},\n {\"series_name\":\"14\",\"author\":\"Peter Clines\"},\n {\"series_name\":\"Blade Runner\",\"author\":\"Phillip K. Dick\"},\n {\"series_name\":\"Unabridged Stories\",\"author\":\"Phillip K. Dick\"},\n {\"series_name\":\"Red Rising\",\"author\":\"Pierce Brown\"},\n {\"series_name\":\"The Wandering Inn\",\"author\":\"Pirate Aba\"},\n {\"series_name\":\"The Quantum'): A Novel of the Fourth Species\",\"author\":\"Rachel Aaron\"},\n {\"series_name\":\"Night Shift\",\"author\":\"Rachel Aaron\"},\n {\"series_name\":\"The Empyrean\",\"author\":\"Rebecca Yarros\"},\n {\"series_name\":\"Exiled Fleet\",\"author\":\"Richard Fox\"},\n {\"series_name\":\"The Last Ditch\",\"author\":\"Richard Fox\"},\n {\"series_name\":\"The Thursday Murder Club\",\"author\":\"Richard Osman\"},\n {\"series_name\":\"The Wheel of Time\",\"author\":\"Robert Jordan\"},\n {\"series_name\":\"Bourne Series\",\"author\":\"Robert Ludlum\"},\n {\"series_name\":\"Street Cultivation\",\"author\":\"Sarah Lin\"},\n {\"series_name\":\"Magic 2.0\",\"author\":\"Scott Meyer\"},\n {\"series_name\":\"He Who Fights with Monsters\",\"author\":\"Shirtaloon\"},\n {\"series_name\":\"Unknown\",\"author\":\"Simon Sinek\"},\n {\"series_name\":\"A Forbidden Alchemy\",\"author\":\"Stacey McEwan\"},\n {\"series_name\":\"The Fall of the Druemaer\",\"author\":\"Terry Brooks\"},\n {\"series_name\":\"Shadow Realm\",\"author\":\"Terry Mancour\"},\n {\"series_name\":\"The Spellmonger Series\",\"author\":\"Terry Mancour\"},\n {\"series_name\":\"Why We Did It\",\"author\":\"Tim Miller\"},\n {\"series_name\":\"The 4-Hour Series\",\"author\":\"Timothy Ferris\"},\n {\"series_name\":\"Jack Ryan Universe\",\"author\":\"Tom Clancy\"},\n {\"series_name\":\"The Beginning After the End\",\"author\":\"TurtleMe\"},\n {\"series_name\":\"The Name of the Rose\",\"author\":\"Umberto Eco\"},\n {\"series_name\":\"Trapped in a Dating Sim - The World of Otome Games is Tough for Mobs\",\"author\":null},\n {\"series_name\":\"The Crowns of Nyaxia\",\"author\":\"Carissa Broadbent\"},\n {\"series_name\":\"Black Ocean Mercy for Hire\",\"author\":\"J S Morin\"},\n {\"series_name\":\"Born with Teeth\",\"author\":\"Kate Mulgrew\"},\n {\"series_name\":\"Dungeon Crawler Carl\",\"author\":\"Matt Dinniman\"},\n {\"series_name\":\"Shadowblade Spellmonger Legacy and Secrets\",\"author\":\"Terry Mancour\"},\n {\"series_name\":\"One Second After\",\"author\":\"William R. Forstchen\"},\n {\"series_name\":\"The Primal Hunter\",\"author\":\"Zogarth\"},\n {\"series_name\":\"86—EIGHTY-SIX\",\"author\":null},\n {\"series_name\":\"Alya Sometimes Hides Her Feelings in Russian\",\"author\":null},\n {\"series_name\":\"Berserk of Gluttony\",\"author\":null},\n {\"series_name\":\"Goblin Slayer\",\"author\":null}\n];\n\nconst testTitle = \"Vijaya Manicavasagar, Derrick Silove - Overcoming Panic, 2nd Edition\";\n\nfunction normalize(str = '') {\n return String(str)\n .toLowerCase()\n .replace(/[^a-z0-9\\\\s]/g, '')\n .replace(/\\\\s+/g, ' ')\n .trim();\n}\n\nconst normalizedTitle = normalize(testTitle);\nlet matches = [];\n\nfor (const series of seriesList) {\n const seriesName = series.series_name || '';\n const author = series.author || '';\n const normalizedSeries = normalize(seriesName);\n const normalizedAuthor = normalize(author);\n\n if (!normalizedSeries) continue;\n\n let score = 0;\n let reasons = [];\n\n // Strategy 1: Direct Series Name inclusion (Original Logic: .includes)\n // Note: We are testing the logic that was active when the error occurred\n if (normalizedTitle.includes(normalizedSeries)) {\n score += 60;\n reasons.push(`includes '${normalizedSeries}'`);\n }\n\n // Strategy 2: Author Match\n if (normalizedAuthor && normalizedTitle.includes(normalizedAuthor)) {\n score += 30;\n reasons.push('author match');\n }\n\n // Strategy 3: Word Intersection\n const titleWords = normalizedTitle.split(' ').filter(w => w.length > 3);\n const seriesWords = normalizedSeries.split(' ').filter(w => w.length > 3);\n const commonWords = titleWords.filter(w => seriesWords.includes(w));\n \n if (commonWords.length > 0) {\n score += commonWords.length * 5;\n reasons.push(`words [${commonWords.join(', ')}]`);\n }\n \n if (score >= 60) {\n matches.push({\n series: seriesName,\n norm: normalizedSeries,\n score,\n reasons\n });\n }\n}\n\nreturn [{\n json: {\n testTitle,\n normalizedTitle,\n matches\n }\n}];" }, "position": [ 440, 140 ], "type": "n8n-nodes-base.code", "typeVersion": 2 } ], "connections": { "Code": { "main": [ [] ] }, "Manual": { "main": [ [ { "index": 0, "node": "Code", "type": "main" } ] ] } }, "settings": { "executionOrder": "v1", "saveDataErrorExecution": "all", "saveDataSuccessExecution": "all", "saveManualExecutions": true, "saveExecutionProgress": true }, "triggerCount": 0, "versionId": "0d8660b7-c143-48f6-8f5f-720ac6b8e28d", "owner": { "type": "personal", "projectId": "FeLO36wNUAcn61Wj", "projectName": "Ben W ", "personalEmail": "admin@ben.io" }, "parentFolderId": null, "isArchived": true }