Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/changing-loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 3 additions & 1 deletion src/core/alternatives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function hitToProject(hit: ModrinthSearchHit): ProjectRef {
}

const LOADER_WORDS = new Set<string>(LOADERS);
const MIN_SHARED_KEYWORDS = 2;

// Poids du score de pertinence (sur 100).
const WEIGHTS = { categories: 40, name: 30, keywords: 10, popularity: 20 };
Expand Down Expand Up @@ -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,
};
}

Expand Down
19 changes: 19 additions & 0 deletions test/core/alternatives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
6 changes: 3 additions & 3 deletions test/fixtures/modrinth/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down Expand Up @@ -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"
],
Expand All @@ -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"
],
Expand Down
Loading