regommend: github.com/muesli/regommend Index | Files | Directories

package regommend

import "github.com/muesli/regommend"

Index

Package Files

regommend.go regommenditem.go regommendtable.go similarity.go

type DistancePair Uses

type DistancePair struct {
    Key      interface{}
    Distance float64
}

type DistancePairList Uses

type DistancePairList []DistancePair

func (DistancePairList) Len Uses

func (p DistancePairList) Len() int

func (DistancePairList) Less Uses

func (p DistancePairList) Less(i, j int) bool

func (DistancePairList) Swap Uses

func (p DistancePairList) Swap(i, j int)

type RegommendItem Uses

type RegommendItem struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

Structure of an item in the recommendation engine. Parameter data contains the user-set value in the engine.

func CreateRegommendItem Uses

func CreateRegommendItem(key interface{}, data map[interface{}]float64) RegommendItem

CreateRegommendItem returns a newly created RegommendItem. Parameter key is the item's key. Parameter data is the item's value.

func (*RegommendItem) Data Uses

func (item *RegommendItem) Data() map[interface{}]float64

Data returns the value of this item.

func (*RegommendItem) Key Uses

func (item *RegommendItem) Key() interface{}

Key returns the key of this item.

type RegommendTable Uses

type RegommendTable struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

Structure of a table with items in the engine.

func Table Uses

func Table(table string) *RegommendTable

Table returns the existing engine table with given name or creates a new one if the table does not exist yet.

func (*RegommendTable) Add Uses

func (table *RegommendTable) Add(key interface{}, data map[interface{}]float64) *RegommendItem

Add adds a key/value pair to the engine. Parameter key is the item's engine-key. Parameter data is the item's value.

func (*RegommendTable) Count Uses

func (table *RegommendTable) Count() int

Count returns how many items are currently stored in the engine.

func (*RegommendTable) Delete Uses

func (table *RegommendTable) Delete(key interface{}) (*RegommendItem, error)

Delete an item from the engine.

func (*RegommendTable) Exists Uses

func (table *RegommendTable) Exists(key interface{}) bool

Test whether an item exists in the engine. Unlike the Value method Exists neither tries to fetch data via the loadData callback nor does it keep the item alive in the engine.

func (*RegommendTable) Flush Uses

func (table *RegommendTable) Flush()

Delete all items from engine.

func (*RegommendTable) Neighbors Uses

func (table *RegommendTable) Neighbors(key interface{}) (DistancePairList, error)

func (*RegommendTable) Recommend Uses

func (table *RegommendTable) Recommend(key interface{}) (DistancePairList, error)

func (*RegommendTable) SetAboutToDeleteItemCallback Uses

func (table *RegommendTable) SetAboutToDeleteItemCallback(f func(*RegommendItem))

Configures a callback, which will be called every time an item is about to be removed from the engine.

func (*RegommendTable) SetAddedItemCallback Uses

func (table *RegommendTable) SetAddedItemCallback(f func(*RegommendItem))

Configures a callback, which will be called every time a new item is added to the engine.

func (*RegommendTable) SetDataLoader Uses

func (table *RegommendTable) SetDataLoader(f func(interface{}) *RegommendItem)

Configures a data-loader callback, which will be called when trying to use access a non-existing key.

func (*RegommendTable) SetLogger Uses

func (table *RegommendTable) SetLogger(logger *log.Logger)

Sets the logger to be used by this engine table.

func (*RegommendTable) Value Uses

func (table *RegommendTable) Value(key interface{}) (*RegommendItem, error)

Value gets an item from the engine and mark it to be kept alive.

Directories

PathSynopsis
example

Package regommend imports 7 packages (graph) and is imported by 6 packages. Updated 2019-08-15. Refresh now. Tools for package owners.