scoring

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentTimestamp

func CurrentTimestamp() int64

CurrentTimestamp returns the current Unix timestamp

Types

type Config

type Config struct {
	// Word boundary bonus (match after /, -, _, ., space)
	WordBoundaryBonus float64
	// Consecutive match bonus
	ConsecutiveBonus float64
	// Prefix match bonus (match at start)
	PrefixBonus float64
	// CamelCase bonus (match at uppercase letter)
	CamelCaseBonus float64
	// Recency bonus settings
	MaxRecencyBonus float64
	// Current branch bonus (git mode only)
	CurrentBranchBonus float64
}

Config holds configuration for the unified scoring algorithm

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default scoring configuration inspired by fzy and fzf algorithms

func (Config) ItemScore

func (c Config) ItemScore(text string, fuzzyScore int, matchedIndexes []int, timestamp int64, isCurrent bool, now int64) float64

ItemScore calculates the total score for an item combining fuzzy match score, position bonuses, and recency

func (Config) MatchBonus

func (c Config) MatchBonus(text string, matchedIndexes []int) float64

MatchBonus calculates bonus score based on match positions using fzy/fzf-inspired algorithm

func (Config) RecencyBonus

func (c Config) RecencyBonus(timestamp, now int64) float64

RecencyBonus calculates recency bonus using hyperbolic decay Formula: bonus = maxBonus / (1 + ageInHours) This strongly prioritizes recent items:

0h ago -> maxBonus, 1h -> maxBonus/2, 2h -> maxBonus/3, 24h -> maxBonus/25

Jump to

Keyboard shortcuts

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