recommend

package
v0.0.0-...-476b611 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTo

func AddTo(c *gin.Context, r *Recommender)

func Shuffle

func Shuffle[T any](ids []T, n int)

Shuffle shuffles IDs within partitions so that results are in a similar order.

Types

type Recommender

type Recommender struct {
	RecommendFunc  func(context.Context, persist.DBID, []db.Follow) ([]persist.DBID, error)
	LoadFunc       func(context.Context)
	SaveResultFunc func(ctx context.Context, userID persist.DBID, recommendedIDs []persist.DBID) error
	BootstrapFunc  func(ctx context.Context) ([]persist.DBID, error)
	// contains filtered or unexported fields
}

func For

func For(ctx context.Context) *Recommender

func NewRecommender

func NewRecommender(queries *db.Queries, bootstrapF func(context.Context) ([]persist.DBID, error)) *Recommender

func (*Recommender) Loop

func (r *Recommender) Loop(ctx context.Context, ticker *time.Ticker)

Loop is the main event loop that manages access to the currently loaded graph

func (*Recommender) RecommendFromFollowing

func (r *Recommender) RecommendFromFollowing(ctx context.Context, userID persist.DBID, follows []db.Follow) ([]persist.DBID, error)

UsersFromFollowing suggest users based on a given user's follows sorted in descending order.

func (*Recommender) RecommendFromFollowingShuffled

func (r *Recommender) RecommendFromFollowingShuffled(ctx context.Context, userID persist.DBID, follows []db.Follow) ([]persist.DBID, error)

UsersFromFollowingShuffled re-orders ranked suggestions to generate more diverse results.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL