Open
Conversation
部分代码来自主线 2.12.3 更新
审阅者指南通过引入结构化的 SearchSource 抽象(支持别名)、改进关键词提取和权重分配、增加 CurseForge 特有的搜索文本处理、调优评分逻辑,并做若干相关 API 与数据清理改动,从而优化多语言搜索系统(尤其是中文查询),覆盖模组、收藏、本地文件、存档以及帮助页面等场景。 带 CurseForge 特殊处理的中文模组搜索时序图sequenceDiagram
actor User
participant UI_SearchBox
participant ModSearchService
participant CurseForgeAPI
participant ModrinthAPI
User->>UI_SearchBox: 输入中文关键词
UI_SearchBox->>ModSearchService: StartSearch(filter)
ModSearchService->>ModSearchService: Build SearchEntry list
ModSearchService->>ModSearchService: Search(entries, SearchText, 40, 0.2)
ModSearchService->>ModSearchService: ExtractWords() per result
ModSearchService->>ModSearchService: Aggregate WordWeights
ModSearchService->>ModSearchService: Choose SearchText and CurseForgeAltSearchText
ModSearchService->>ModSearchService: processKeywords(SearchText)
ModSearchService->>ModSearchService: processKeywords(CurseForgeAltSearchText)
ModSearchService->>CurseForgeAPI: GET /mods?searchFilter=CurseForgeAltSearchText
ModSearchService->>ModrinthAPI: GET /search?query=SearchText
CurseForgeAPI-->>ModSearchService: CurseForge results
ModrinthAPI-->>ModSearchService: Modrinth results
ModSearchService->>UI_SearchBox: Display merged search results
带有 SearchSource 和 SearchEntry 的更新搜索模型类图classDiagram
class SearchEntry_T_ {
+T Item
+List_SearchSource_ SearchSource
+double Similarity
+bool AbsoluteRight
}
class SearchSource {
+string[] Aliases
+double Weight
+SearchSource(aliases string[], weight double)
+SearchSource(text string, weight double)
}
class SearchModule {
+double SearchSimilarityWeighted(source List_SearchSource_, query string)
+List_SearchEntry_T_ Search(entries List_SearchEntry_T_, query string, maxBlurCount int, minBlurSimilarity double)
}
class CompSearchRequest {
+string SearchText
+string CurseForgeAltSearchText
}
SearchEntry_T_ --> SearchSource : uses *
SearchModule --> SearchSource : weights
SearchModule --> SearchEntry_T_ : evaluates
SearchModule --> CompSearchRequest : fills
文件级改动
可能关联的问题
提示与命令与 Sourcery 交互
自定义你的使用体验打开你的 控制面板 以:
获取帮助Original review guide in EnglishReviewer's GuideRefines the multilingual search system (especially for Chinese queries) across mods, favorites, local files, saves, and help pages by introducing a structured SearchSource abstraction with aliases, improving keyword extraction and weighting, adding CurseForge-specific search text handling, tuning scoring, and making a few related API and data-cleanup adjustments. Sequence diagram for refined Chinese mod search with CurseForge-specific handlingsequenceDiagram
actor User
participant UI_SearchBox
participant ModSearchService
participant CurseForgeAPI
participant ModrinthAPI
User->>UI_SearchBox: 输入中文关键词
UI_SearchBox->>ModSearchService: StartSearch(filter)
ModSearchService->>ModSearchService: Build SearchEntry list
ModSearchService->>ModSearchService: Search(entries, SearchText, 40, 0.2)
ModSearchService->>ModSearchService: ExtractWords() per result
ModSearchService->>ModSearchService: Aggregate WordWeights
ModSearchService->>ModSearchService: Choose SearchText and CurseForgeAltSearchText
ModSearchService->>ModSearchService: processKeywords(SearchText)
ModSearchService->>ModSearchService: processKeywords(CurseForgeAltSearchText)
ModSearchService->>CurseForgeAPI: GET /mods?searchFilter=CurseForgeAltSearchText
ModSearchService->>ModrinthAPI: GET /search?query=SearchText
CurseForgeAPI-->>ModSearchService: CurseForge results
ModrinthAPI-->>ModSearchService: Modrinth results
ModSearchService->>UI_SearchBox: Display merged search results
Class diagram for updated search model with SearchSource and SearchEntryclassDiagram
class SearchEntry_T_ {
+T Item
+List_SearchSource_ SearchSource
+double Similarity
+bool AbsoluteRight
}
class SearchSource {
+string[] Aliases
+double Weight
+SearchSource(aliases string[], weight double)
+SearchSource(text string, weight double)
}
class SearchModule {
+double SearchSimilarityWeighted(source List_SearchSource_, query string)
+List_SearchEntry_T_ Search(entries List_SearchEntry_T_, query string, maxBlurCount int, minBlurSimilarity double)
}
class CompSearchRequest {
+string SearchText
+string CurseForgeAltSearchText
}
SearchEntry_T_ --> SearchSource : uses *
SearchModule --> SearchSource : weights
SearchModule --> SearchEntry_T_ : evaluates
SearchModule --> CompSearchRequest : fills
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我在这里给出了一些高层次的反馈:
- 在
Search中,processedSources现在是一个List(Of String()),并且在构建之后似乎没有再被使用;如果你的意图只是就地规范化Aliases,可以考虑把当前的Select改成对Entry.SearchSource做一个简单的For Each,并完全去掉processedSources,以避免混淆和不必要的内存分配。 - 在
ExtractWordslambda 中,条件If w.Split(" ").Count > 3 AndAlso w.Contains("ftb") Then Return False永远不可能为真,因为w已经是单个 token(不包含空格);建议移除或重写这个检查,让 FTB 的特殊处理逻辑能按预期生效。 - 新的
SearchSimilarityWeighted实现假定totalWeight > 0;如果调用方传入的是空的或全部为 0 的SearchSource列表,会导致除以 0 的错误,因此在totalWeight为 0 时提前返回 0 可能会更安全。
给 AI 智能体的提示
Please address the comments from this code review:
## Overall Comments
- 在 `Search` 中,`processedSources` 现在是一个 `List(Of String())`,并且在构建之后似乎没有再被使用;如果你的意图只是就地规范化 `Aliases`,可以考虑把当前的 `Select` 改成对 `Entry.SearchSource` 做一个简单的 `For Each`,并完全去掉 `processedSources`,以避免混淆和不必要的内存分配。
- 在 `ExtractWords` lambda 中,条件 `If w.Split(" ").Count > 3 AndAlso w.Contains("ftb") Then Return False` 永远不可能为真,因为 `w` 已经是单个 token(不包含空格);建议移除或重写这个检查,让 FTB 的特殊处理逻辑能按预期生效。
- 新的 `SearchSimilarityWeighted` 实现假定 `totalWeight > 0`;如果调用方传入的是空的或全部为 0 的 `SearchSource` 列表,会导致除以 0 的错误,因此在 `totalWeight` 为 0 时提前返回 0 可能会更安全。帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈来改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- In
Search,processedSourcesis now aList(Of String())and appears to be unused after being built; if the intent is only to normalizeAliasesin place, consider replacing theSelectwith a simpleFor EachoverEntry.SearchSourceand droppingprocessedSourcesaltogether to avoid confusion and unnecessary allocations. - In the
ExtractWordslambda, the conditionIf w.Split(" ").Count > 3 AndAlso w.Contains("ftb") Then Return Falsewill never be true becausewis already a single token (no spaces); consider removing or rewriting this check so the FTB special case actually works as intended. - The new
SearchSimilarityWeightedimplementation assumestotalWeight > 0; if a caller ever passes an empty or all‑zeroSearchSourcelist this will cause a divide‑by‑zero, so it may be safer to early‑return 0 whentotalWeightis 0.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `Search`, `processedSources` is now a `List(Of String())` and appears to be unused after being built; if the intent is only to normalize `Aliases` in place, consider replacing the `Select` with a simple `For Each` over `Entry.SearchSource` and dropping `processedSources` altogether to avoid confusion and unnecessary allocations.
- In the `ExtractWords` lambda, the condition `If w.Split(" ").Count > 3 AndAlso w.Contains("ftb") Then Return False` will never be true because `w` is already a single token (no spaces); consider removing or rewriting this check so the FTB special case actually works as intended.
- The new `SearchSimilarityWeighted` implementation assumes `totalWeight > 0`; if a caller ever passes an empty or all‑zero `SearchSource` list this will cause a divide‑by‑zero, so it may be safer to early‑return 0 when `totalWeight` is 0.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
部分代码来自主线 2.12.3 更新
来自 Sourcery 的总结
在改进相关元数据处理和日志记录的同时,提高中文资源搜索的准确性和搜索权重。
新功能:
缺陷修复:
改进优化:
Original summary in English
Summary by Sourcery
Improve Chinese resource search accuracy and search weighting while refining related metadata handling and logging.
New Features:
Bug Fixes:
Enhancements: