Skip to content

Commit

Permalink
continuous frecency
Browse files Browse the repository at this point in the history
a curve that seems to fit original behavior pretty closely.

h/t @dcervenkov
  • Loading branch information
rupa committed Oct 24, 2019
1 parent dcd5541 commit 4f08e7f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions z.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,9 @@ _z() {
local cd
cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
function frecent(rank, time) {
# relate frequency and time
dx = t - time
if( dx < 3600 ) return rank * 4
if( dx < 86400 ) return rank * 2
if( dx < 604800 ) return rank / 2
return rank / 4
# relate frequency and time
dx = t - time
return rank * (3.75/((0.0001 * dx + 1) + 0.25))
}
function output(matches, best_match, common) {
# list or return the desired directory
Expand Down

0 comments on commit 4f08e7f

Please sign in to comment.