你的意思...? 如何猜测用户要输入的内容(在 404 页面上)

发布于 2024-07-09 10:40:17 字数 275 浏览 3 评论 0原文

我正在为我的网站自定义 404 页面。 我希望其中包含“您的意思是……?” 我需要弄清楚如何做到这一点。

到目前为止,我正在做的事情是:列出用户可能正在查找的文件的广泛列表,然后使用 levenshtein() 将每个可能的文件名与输入错误的文件名进行比较。 那些差异最小的被选择为“您的意思是吗?”

我也考虑过使用metaphone(),但我认为这可能有点多余。

您对“您的意思是……?”有什么建议 脚本?

I'm customizing the 404 page for my website. I'd like it to include a "Did you mean...?" I need to figure out how to do this.

Here's what I'm doing so far: I come up with a broad list of files that the user might be looking for, then use levenshtein() to compare each possible filename to the mistyped filename. Those with the lowest differences are selected for "Did you mean."

I've also considered using metaphone(), but I think it may be excessive.

What would you suggest for a "Did you mean...?" script?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

西瑶 2024-07-16 10:40:17

您可能需要考虑的一件事是 Google 的 404 脚本,用于执行您提到的操作。 它可能不如定制解决方案那么好,但可能值得尝试一下。

http://googlewebmastercentral.blogspot.com/ 2008/08/make-your-404-pages-more-useful.html

One thing you might want to consider is Google's 404 script for doing just what you mentioned. It probably wouldn't be as good as a custom solution, but it may be worth trying out to be sure.

http://googlewebmastercentral.blogspot.com/2008/08/make-your-404-pages-more-useful.html

吃素的狼 2024-07-16 10:40:17

听起来你想要更多,但是你看过 Apache 的 mod_speling

It sounds like you want more, but have you looked at Apache's mod_speling

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文