Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
PercyDan54 committed Oct 29, 2024
1 parent c0aa7ab commit f70a51d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ private void onSongSearchRequestFinish(RequestFinishMeta meta, APISearchRequest?
return;
}

float similiarPrecentage = meta.GetSimiliarPrecentage();
float similarPercentage = meta.GetSimilarPercentage();

Logging.Log($"Beatmap: '{meta.SourceBeatmap?.Metadata.GetTitle() ?? "???"}' <-> '{meta.GetNeteaseTitle()}' -> {similiarPrecentage} <-> {meta.TitleSimiliarThreshold}");
Logging.Log($"Beatmap: '{meta.SourceBeatmap?.Metadata.GetTitle() ?? "???"}' <-> '{meta.GetNeteaseTitle()}' -> {similarPercentage} <-> {meta.TitleSimilarThreshold}");

if (similiarPrecentage >= meta.TitleSimiliarThreshold)
if (similarPercentage >= meta.TitleSimilarThreshold)
{
//标题匹配,发送歌词查询请求
var req = new APILyricRequest(meta.SongID);
Expand Down Expand Up @@ -257,7 +257,7 @@ private void onSongSearchRequestFinish(RequestFinishMeta meta, APISearchRequest?
this.setState(SearchState.Fail);

Logging.Log($"对 {meta.SourceBeatmap?.Metadata.GetTitle() ?? "未知谱面"} 的标题匹配失败:");
Logging.Log($"Beatmap: '{meta.SourceBeatmap?.Metadata.GetTitle() ?? "???"}' <-> '{meta.GetNeteaseTitle()}' -> {similiarPrecentage} < {meta.TitleSimiliarThreshold}");
Logging.Log($"Beatmap: '{meta.SourceBeatmap?.Metadata.GetTitle() ?? "???"}' <-> '{meta.GetNeteaseTitle()}' -> {similarPercentage} < {meta.TitleSimilarThreshold}");

meta.OnFail?.Invoke("标题匹配失败, 将不会继续搜索歌词...");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public struct RequestFinishMeta
/// <summary>
/// 标题匹配阈值,值越高要求越严格
/// </summary>
public float TitleSimiliarThreshold;
public float TitleSimilarThreshold;

/// <summary>
/// 请求是否成功?
Expand All @@ -41,7 +41,7 @@ public struct RequestFinishMeta
/// 获取网易云歌曲标题和搜索标题的相似度
/// </summary>
/// <returns>相似度百分比</returns>
public float GetSimiliarPrecentage()
public float GetSimilarPercentage()
{
string neteaseTitle = GetNeteaseTitle().ToLowerInvariant();
string ourTitle = SourceBeatmap?.Metadata.GetTitle().ToLowerInvariant() ?? string.Empty;
Expand All @@ -52,9 +52,9 @@ public float GetSimiliarPrecentage()
if (string.IsNullOrEmpty(neteaseTitle) || string.IsNullOrEmpty(ourTitle)) return 0;

int distance = LevenshteinDistance.Compute(source, target);
float precentage = 1 - (distance / (float)source.Length);
float percentage = 1 - (distance / (float)source.Length);

return Math.Abs(precentage);
return Math.Abs(percentage);
}

public string GetNeteaseTitle()
Expand Down Expand Up @@ -89,7 +89,7 @@ public static RequestFinishMeta Fail(WorkingBeatmap? beatmap = null)
/// <param name="sourceBeatmap">和此Meta对应的<see cref="WorkingBeatmap"/>></param>
/// <param name="onFinish">完成时要进行的动作</param>
/// <param name="onFail">失败时要进行的动作</param>
/// <param name="titleSimiliarThreshold"><see cref="TitleSimiliarThreshold"/></param>
/// <param name="titleSimiliarThreshold"><see cref="TitleSimilarThreshold"/></param>
/// <returns>通过参数构建的<see cref="RequestFinishMeta"/>></returns>
public static RequestFinishMeta From(APISearchResponseRoot responseRoot, WorkingBeatmap? sourceBeatmap,
Action<APILyricResponseRoot>? onFinish, Action<string>? onFail,
Expand All @@ -102,7 +102,7 @@ public static RequestFinishMeta From(APISearchResponseRoot responseRoot, Working
SearchResponseRoot = responseRoot,
Success = (responseRoot.Result?.Songs?.First().ID ?? -1) > 0,
SourceBeatmap = sourceBeatmap,
TitleSimiliarThreshold = titleSimiliarThreshold
TitleSimilarThreshold = titleSimiliarThreshold
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static SearchOption FromRequestFinishMeta(RequestFinishMeta requestFinish
OnFinish = requestFinishMeta.OnFinish,
OnFail = requestFinishMeta.OnFail,

TitleSimiliarThreshold = requestFinishMeta.TitleSimiliarThreshold
TitleSimiliarThreshold = requestFinishMeta.TitleSimilarThreshold
};
}
}
Expand Down

0 comments on commit f70a51d

Please sign in to comment.