Hugo的相关内容算法是如何工作的?有哪些因素?

huangapple go评论84阅读模式
英文:

How does Hugo's Related Content algorithm work? What are the factors?

问题

在他们的网站上,他们说:

> Hugo使用一组因素根据Front Matter参数来识别页面的相关内容。这可以根据所需的索引和参数进行调整,或者使用Hugo的默认相关内容配置。

来源

但是算法究竟是如何工作的?有哪些因素?

英文:

On their website they say:

> Hugo uses a set of factors to identify a page’s related content based on Front Matter parameters. This can be tuned to the desired set of indices and parameters or left to Hugo’s default Related Content configuration.

Source

But how exactly does the algorithmus work? What are the factors?

答案1

得分: 1

这个原始方法在gohugoio/hugo PR 3815中有解释。

> 已经尝试了几次修复#98 -- 但是所有尝试都因为某些原因失败了。
解决这个问题很困难,我认为失败的主要原因是自下而上的方法,也就是我们从最困难的问题开始:解决夏洛克的最后一个案例
>
> 我现在重新开始处理这个问题的原因是这个 Twitter 线程
>
> 在页面参数中使用交集和关键词可以工作得相当好,但是它是二次的,对于较大的网站来说速度会很慢,无法使用。
>
> 因此,我开始通过概述一个接口来解决这个 PR:
>
> go >type PageSearcher interface { > Search(args ...interface{}) (Pages, error) > SearchIndex(index string, args ...interface{}) (Pages, error) > Similar(p *Page) (Pages, error) > SimilarIndex(index string, p *Page) (Pages, error) >} >
>欢迎提出命名建议。
>
>这个想法是用户在 config.toml 中定义一组索引:
> toml >indexes: > - param: keywords > weight: 1 > - param: tags > weight: 3 >
>然后我们从中惰性地构建某种索引,然后你可以进行快速搜索,例如:
>
> go >{{ .Site.RegularPages.Similar . }} >{{ .Site.RegularPages.Search "hugo" }} >{{ .Site.RegularPages.SearchIndex "keywords" "hugo" | limit 10 }} >

初始实现:gohugoio/hugo commit 3b4f17b

英文:

The original approach is explained in gohugoio/hugo PR 3815

> Several attempts have been started to fix #98 -- all of them have failed for some reason.
It is a hard problem to solve, and I think the main reason for failure has been the bottom-up-approach, i.e. we have started with the hardest problem: Solving Sherlock's last case.
>
> The reason I'm picking up this ball again now is this Twitter thread:
>
> Using intersect and keywords in page params work reasonably well, but it is quadratic and will be slow to unusable for larger sites.
>
> So, instead of solving the hardest problem, I have started on this PR by outlining an interface:
>
> go
>type PageSearcher interface {
> Search(args ...interface{}) (Pages, error)
> SearchIndex(index string, args ...interface{}) (Pages, error)
> Similar(p *Page) (Pages, error)
> SimilarIndex(index string, p *Page) (Pages, error)
>}
>

>Naming suggestions welcomed.
>
>The idea is that a user defines a set of indexes in config.toml:
> toml
>indexes:
> - param: keywords
> weight: 1
> - param: tags
> weight: 3
>

>Then we lazily build some sort of index from that, and then you can do fast searches like:
>
> go
>{{ .Site.RegularPages.Similar . }}
>{{ .Site.RegularPages.Search "hugo" }}
>{{ .Site.RegularPages.SearchIndex "keywords" "hugo" | limit 10 }}
>

Initial implementation: gohugoio/hugo commit 3b4f17b

huangapple
  • 本文由 发表于 2022年3月1日 06:42:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/71301849.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定