client

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 5 Imported by: 2

README

Gorse Client

Go SDK for Gorse recommender system.

⚠️⚠️⚠️ This SDK is unstable currently. APIs might be changed in later versions.

Install

go get github.com/zhenghaoz/gorse/client@master

Usage

import "github.com/zhenghaoz/gorse/client"

func main() {
    gorse = client.NewGorseClient("http://127.0.0.1:8087", "api_key")
	resp, err := gorse.InsertFeedback([]client.Feedback{{
		FeedbackType: "read",
		UserId:       userId,
		Timestamp:    timestamp,
		ItemId:       "300",
	}})
}

Test

In the root directory of Gorse source:

# Setup Gorse
docker-compose up -d

# Test
go test -tags='integrate_test' ./client/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorMessage

type ErrorMessage string

func (ErrorMessage) Error

func (e ErrorMessage) Error() string

type Feedback

type Feedback struct {
	FeedbackType string `json:"FeedbackType"`
	UserId       string `json:"UserId"`
	ItemId       string `json:"ItemId"`
	Timestamp    string `json:"Timestamp"`
}

type GorseClient

type GorseClient struct {
	// contains filtered or unexported fields
}

func NewGorseClient

func NewGorseClient(EntryPoint, ApiKey string) *GorseClient

func (*GorseClient) DeleteItem

func (c *GorseClient) DeleteItem(itemId string) (RowAffected, error)

func (*GorseClient) DeleteUser

func (c *GorseClient) DeleteUser(userId string) (RowAffected, error)

func (*GorseClient) GetItem

func (c *GorseClient) GetItem(itemId string) (Item, error)

func (*GorseClient) GetNeighbors

func (c *GorseClient) GetNeighbors(itemId string, n int) ([]Score, error)

func (*GorseClient) GetRecommend

func (c *GorseClient) GetRecommend(userId string, category string, n int) ([]string, error)

func (*GorseClient) GetUser

func (c *GorseClient) GetUser(userId string) (User, error)

func (*GorseClient) InsertFeedback

func (c *GorseClient) InsertFeedback(feedbacks []Feedback) (RowAffected, error)

func (*GorseClient) InsertItem

func (c *GorseClient) InsertItem(item Item) (RowAffected, error)

func (*GorseClient) InsertUser

func (c *GorseClient) InsertUser(user User) (RowAffected, error)

func (*GorseClient) ListFeedbacks

func (c *GorseClient) ListFeedbacks(feedbackType, userId string) ([]Feedback, error)

func (*GorseClient) SessionRecommend

func (c *GorseClient) SessionRecommend(feedbacks []Feedback, n int) ([]Score, error)

type Item

type Item struct {
	ItemId     string   `json:"ItemId"`
	IsHidden   bool     `json:"IsHidden"`
	Labels     []string `json:"Labels"`
	Categories []string `json:"Categories"`
	Timestamp  string   `json:"Timestamp"`
	Comment    string   `json:"Comment"`
}

type RowAffected

type RowAffected struct {
	RowAffected int `json:"RowAffected"`
}

type Score

type Score struct {
	Id    string `json:"Id"`
	Score int    `json:"Score"`
}

type User

type User struct {
	UserId    string   `json:"UserId"`
	Labels    []string `json:"Labels"`
	Subscribe []string `json:"Subscribe"`
	Comment   string   `json:"Comment"`
}

Jump to

Keyboard shortcuts

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