1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

increment path weights on a log scale

This commit is contained in:
William Ting 2012-05-06 15:54:27 -10:00
parent 900e3889e7
commit f98b13641f

View File

@ -2,6 +2,7 @@
from __future__ import division, print_function from __future__ import division, print_function
import argparse import argparse
import math
from operator import itemgetter from operator import itemgetter
import os import os
import re import re
@ -34,10 +35,12 @@ class Database:
self.data = {} self.data = {}
self.load() self.load()
# TODO: increase logarithmically as opposed to linear def add(self, path, increment=1):
def add(self, key, increment = 1):
""" Increment existing paths or initialize new ones to 0. """ """ Increment existing paths or initialize new ones to 0. """
self.data[key] = self.data.get(key, 0.) + increment if path not in self.data:
self.data[path] = 10
else:
self.data[path] = math.sqrt((self.data[path]**2)+100)
def decay(self): def decay(self):
""" Decay database entries. """ """ Decay database entries. """