diff --git a/CHANGELOG.md b/CHANGELOG.md index d69df01..3b3f4a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,8 @@ All notable changes to ModShift are documented here. The format follows ### Fixed - Unrelated alternatives: a popular mod sharing only a broad category (e.g. Xaero's Minimap for - CIT Resewn) is no longer suggested; a candidate needs a similar name or a shared keyword. + CIT Resewn) is no longer suggested; a candidate needs a similar name or two shared keywords + (one generic word such as "screen" is not enough). - A dependency published only for another loader (e.g. KotlinLangForge, NeoForge only, declared by Zoomify's single Fabric + NeoForge file) is no longer reported as missing for the target; a warning explains why it was ignored. diff --git a/README.md b/README.md index f07441e..36a9c5a 100644 --- a/README.md +++ b/README.md @@ -296,8 +296,8 @@ For each mod, in this order: 2. **Alternatives**, when the project has no version for the target. Candidates come from two Modrinth searches (similar name, same categories) filtered on the target, then are **ranked by relevance** (shared categories 40 %, similar name 30 %, popularity 20 %, keywords from the - description 10 %). A candidate must have a similar name or share a meaningful keyword with - the original's description: a popular mod that only shares a broad category (such as + description 10 %). A candidate must have a similar name or share at least two meaningful keywords + with the original's description: a popular mod that only shares a broad category (such as "utility") is not suggested. Each suggestion comes with its score and why it was chosen, for example `relevance 79/100 — similar name (minimap) · same categories (adventure, utility) · 1.0M downloads`. diff --git a/docs/guide/changing-loader.md b/docs/guide/changing-loader.md index b034f4d..2a77460 100644 --- a/docs/guide/changing-loader.md +++ b/docs/guide/changing-loader.md @@ -14,8 +14,8 @@ For each mod, in this order: 2. **Alternatives**, when the project has no version for the target. Candidates come from two Modrinth searches (similar name, same categories) filtered on the target, then are **ranked by relevance** (shared categories 40 %, similar name 30 %, popularity 20 %, keywords from the - description 10 %). A candidate must have a similar name or share a meaningful keyword with - the original's description: a popular mod that only shares a broad category (such as + description 10 %). A candidate must have a similar name or share at least two meaningful keywords + with the original's description: a popular mod that only shares a broad category (such as "utility") is not suggested. Each suggestion comes with its score and why it was chosen, for example `relevance 79/100 — similar name (minimap) · same categories (adventure, utility) · 1.0M downloads`. diff --git a/src/core/alternatives.ts b/src/core/alternatives.ts index deb0cc3..00907b1 100644 --- a/src/core/alternatives.ts +++ b/src/core/alternatives.ts @@ -15,6 +15,7 @@ function hitToProject(hit: ModrinthSearchHit): ProjectRef { } const LOADER_WORDS = new Set(LOADERS); +const MIN_SHARED_KEYWORDS = 2; // Poids du score de pertinence (sur 100). const WEIGHTS = { categories: 40, name: 30, keywords: 10, popularity: 20 }; @@ -69,7 +70,8 @@ export function scoreAlternative( score, explanation: parts.join(' · '), nameMatch: sharedTitle.length > 0, - keywordMatch: extraKeywords.length > 0, + // Un seul mot commun (ex. « screen ») est trop faible : deux au moins sans nom proche. + keywordMatch: extraKeywords.length >= MIN_SHARED_KEYWORDS, }; } diff --git a/test/core/alternatives.test.ts b/test/core/alternatives.test.ts index e4ba8c1..0675443 100644 --- a/test/core/alternatives.test.ts +++ b/test/core/alternatives.test.ts @@ -78,4 +78,23 @@ describe('scoreAlternative', () => { expect(result.nameMatch).toBe(false); expect(result.keywordMatch).toBe(false); }); + + it('needs two shared keywords without a similar name (real-run regression)', () => { + // Cas observé : Xaero's Minimap proposé pour Paginated Advancements à cause du seul mot « screen ». + const original = { + title: 'Paginated Advancements & Custom Frames', + categories: ['fabric', 'utility'], + description: 'Makes the advancements screen paginated and bigger.', + }; + const oneWord = scoreAlternative( + hit({ title: "Xaero's Minimap", description: 'A minimap on your screen.' }), + original, + ); + expect(oneWord.keywordMatch).toBe(false); + const twoWords = scoreAlternative( + hit({ title: 'Better Progress', description: 'A bigger, paginated progress screen.' }), + original, + ); + expect(twoWords.keywordMatch).toBe(true); + }); }); diff --git a/test/fixtures/modrinth/catalog.json b/test/fixtures/modrinth/catalog.json index 94f2bb6..60eaf83 100644 --- a/test/fixtures/modrinth/catalog.json +++ b/test/fixtures/modrinth/catalog.json @@ -5,7 +5,7 @@ "id": "AANobbMI", "slug": "sodium", "title": "Sodium", - "description": "Sodium (fixture)", + "description": "A modern rendering engine that greatly improves frame rates and stuttering.", "categories": [ "optimization" ], @@ -254,7 +254,7 @@ "id": "RUBIDIUM", "slug": "rubidium", "title": "Rubidium", - "description": "Rubidium (fixture)", + "description": "Unofficial port of Sodium: a rendering engine that greatly improves frame rates.", "categories": [ "optimization" ], @@ -273,7 +273,7 @@ "id": "EMBEDIUM", "slug": "embeddium", "title": "Embeddium", - "description": "Embeddium (fixture)", + "description": "Fork of the Sodium rendering engine that improves frame rates.", "categories": [ "optimization" ],