contnet

package
v0.0.0-...-c6b3300 Latest Latest
Warning

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

Go to latest
Published: May 5, 2015 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActionArgumentTypes = struct {
	Unknown ActionArgumentType
	Integer ActionArgumentType
	String  ActionArgumentType
	Float   ActionArgumentType
}{
	Unknown: action_argument_type_unknown,
	Integer: action_argument_type_integer,
	String:  action_argument_type_string,
	Float:   action_argument_type_float,
}
View Source
var ActionTypes = struct {
	None     ActionType
	Read     ActionType
	Upvote   ActionType
	Downvote ActionType
}{
	None:     action_none,
	Read:     action_read,
	Upvote:   action_upvote,
	Downvote: action_downvote,
}
View Source
var ContentKeywordExtractor = keywordExtractor{}
View Source
var Errors = struct {
	NotImplemented  error
	ContentNotFound error
	ProfileNotFound error
}{
	NotImplemented:  errors.New("Not implemented."),
	ContentNotFound: errors.New("Content not found in content store."),
	ProfileNotFound: errors.New("Profile not found in profile store."),
}
View Source
var Object = struct {
	Topic          TopicFactory
	Content        ContentFactory
	ContentStore   ContentStoreFactory
	TopicInterest  TopicInterestFactory
	Profile        ProfileFactory
	ProfileStore   ProfileStoreFactory
	Index          IndexFactory
	Net            NetFactory
	Action         ActionFactory
	ActionArgument ActionArgumentFactory
	TrendStore     TrendStoreFactory
}{
	Topic:          TopicFactory{},
	Content:        ContentFactory{},
	ContentStore:   ContentStoreFactory{},
	TopicInterest:  TopicInterestFactory{},
	Profile:        ProfileFactory{},
	ProfileStore:   ProfileStoreFactory{},
	Index:          IndexFactory{},
	Net:            NetFactory{},
	Action:         ActionFactory{},
	ActionArgument: ActionArgumentFactory{},
	TrendStore:     TrendStoreFactory{},
}

registry of all object factories

Functions

This section is empty.

Types

type Action

type Action struct {
	ProfileID ID `json:"profileID"`
	ContentID ID `json:"contentID"`
	Content   *Content
	Type      ActionType      `json:"type"`
	Arguments ActionArguments `json:"arguments"`
	Timestamp time.Time       `json:"timestamp"`
}

type ActionArgument

type ActionArgument struct {
	Name  string             `json:"name"`
	Type  ActionArgumentType `json:"type"`
	Value interface{}        `json:"value"`
}

func (*ActionArgument) Clone

func (arg *ActionArgument) Clone() *ActionArgument

func (*ActionArgument) GetValueInteger

func (arg *ActionArgument) GetValueInteger() int

type ActionArgumentFactory

type ActionArgumentFactory struct{}

func (ActionArgumentFactory) New

func (factory ActionArgumentFactory) New(name string, argType ActionArgumentType, value interface{}) *ActionArgument

type ActionArgumentType

type ActionArgumentType uint8

type ActionArguments

type ActionArguments []*ActionArgument

func (ActionArguments) Clone

func (args ActionArguments) Clone() ActionArguments

func (ActionArguments) GetArgumentByName

func (args ActionArguments) GetArgumentByName(name string) *ActionArgument

type ActionFactory

type ActionFactory struct{}

func (ActionFactory) New

func (factory ActionFactory) New(profileID, contentID ID, actionType ActionType, timestamp time.Time, args ActionArguments) *Action

type ActionType

type ActionType uint8

type Content

type Content struct {
	ID         ID        `json:"id"`
	Keywords   Keywords  `json:"keywords"`
	CreatedAt  time.Time `json:"createdAt"`
	Quality    float64   `json:"quality"`
	Popularity float64   `json:"popularity"`

	// virtual attribute
	Age time.Time `json:"age"`
}

Content object contains information pertinent to content being indexed by ContNet.

func (*Content) Clone

func (content *Content) Clone() *Content

Content object clone (deep copy)

type ContentBy

type ContentBy func(c1, c2 *Content) bool

function that defines ordering between content objects

func (ContentBy) Sort

func (contentBy ContentBy) Sort(contents []*Content)

method on the function type, sorts the argument slice according to the function

type ContentFactory

type ContentFactory struct{}

func (ContentFactory) New

func (factory ContentFactory) New(id ID, keywords Keywords, createdAt time.Time, quality, popularity float64) *Content

Creates new content object

type ContentKeywordExtractionInput

type ContentKeywordExtractionInput struct {
	Title       string
	Description string
	Comments    []string
}

type ContentStore

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

func (*ContentStore) Count

func (store *ContentStore) Count() int

func (*ContentStore) Describe

func (store *ContentStore) Describe() []*Content

func (*ContentStore) Get

func (store *ContentStore) Get(id ID) *Content

func (*ContentStore) GetAllContentIDs

func (store *ContentStore) GetAllContentIDs() []ID

func (*ContentStore) GetAnyContentID

func (store *ContentStore) GetAnyContentID() ID

I know this relies on the fact that range order is UNSPECIFIED and thus behaves quasi-randomly..

func (*ContentStore) GetMany

func (store *ContentStore) GetMany(ids []ID) []*Content

func (*ContentStore) RestoreFromSnapshot

func (store *ContentStore) RestoreFromSnapshot(path, filename string) error

func (*ContentStore) Snapshot

func (store *ContentStore) Snapshot(path, filename string) error

func (*ContentStore) Upsert

func (store *ContentStore) Upsert(content *Content)

type ContentStoreFactory

type ContentStoreFactory struct{}

func (ContentStoreFactory) New

func (factory ContentStoreFactory) New(config *NetConfig, bus *EventBus.EventBus) *ContentStore

type ID

type ID int64

type Index

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

func (*Index) Describe

func (index *Index) Describe() []*IndexNodeDescription

func (*Index) GetForTopics

func (index *Index) GetForTopics(topics Topics) [][]ID

func (*Index) Index

func (index *Index) Index(content *Content)

Index previously unindexed content.

func (*Index) Reindex

func (index *Index) Reindex(old, new *Content)

func (*Index) Remove

func (index *Index) Remove(content *Content)

func (*Index) RestoreFromSnapshot

func (index *Index) RestoreFromSnapshot(path, filename string) error

func (*Index) Snapshot

func (index *Index) Snapshot(path, filename string) error

type IndexFactory

type IndexFactory struct{}

func (IndexFactory) New

func (factory IndexFactory) New(config *NetConfig, bus *EventBus.EventBus, contentStore *ContentStore) *Index

type IndexNodeDescription

type IndexNodeDescription struct {
	Keyword1 Keyword
	Keyword2 Keyword
	IDs      []ID
}

type Interest

type Interest float64

Interest is a floating point value that represents the level of user's interest.

type Keyword

type Keyword uint32

Keyword is represented by its unique id which is of type unsigned int32.

type Keywords

type Keywords []Keyword

Keywords is a type representing a slice of keywords.

func (Keywords) Clone

func (keywords Keywords) Clone() Keywords

func (Keywords) GetTopics

func (keywords Keywords) GetTopics() Topics

Gets all topics based on keywords, e.g. Keywords: A, B, C Topics: AB, AC, BC

type Net

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

func (*Net) Describe

func (net *Net) Describe() *NetDescription

func (*Net) Restore

func (net *Net) Restore() error

func (*Net) SaveAction

func (net *Net) SaveAction(action *Action) error

Attempts to update network object with action for profile specified.

func (*Net) SaveContent

func (net *Net) SaveContent(content *Content)

Attempts to update network object with content specified. If content did not exist, it is added to the network. If content did exist, it is updated.

func (*Net) Select

func (net *Net) Select(profileID int64, page uint8) []ID

func (*Net) Snapshot

func (net *Net) Snapshot() error

type NetConfig

type NetConfig struct {
	MaxContentAge           time.Duration
	CheckContentAgeInterval time.Duration
	ItemsPerPage            uint8
	NoveltyPct              float64
	SnapshotPath            string
	SnapshotInterval        time.Duration
}

type NetDescription

type NetDescription struct {
	Contents []*Content
	Index    []*IndexNodeDescription
	Profiles []*ProfileDescription
	Trends   []*TrendDescription
}

type NetFactory

type NetFactory struct{}

func (NetFactory) New

func (factory NetFactory) New(config *NetConfig) *Net

type Profile

type Profile struct {
	ID             ID
	TopicInterests TopicInterests
}

Profile contains information about topic interests for specified content consumer.

func (*Profile) Clone

func (profile *Profile) Clone() *Profile

func (*Profile) Describe

func (profile *Profile) Describe() *ProfileDescription

func (*Profile) SaveAction

func (profile *Profile) SaveAction(action *Action)

Thread-safe profile object update with action

type ProfileDescription

type ProfileDescription struct {
	ID             ID                          `json:"id"`
	TopicInterests []*TopicInterestDescription `json:"topicInterests"`
}

type ProfileFactory

type ProfileFactory struct{}

func (ProfileFactory) New

func (factory ProfileFactory) New(id ID, topicInterests TopicInterests) *Profile

Creates new Profile object

type ProfileStore

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

func (*ProfileStore) Delete

func (store *ProfileStore) Delete(id ID)

func (*ProfileStore) Describe

func (store *ProfileStore) Describe() []*ProfileDescription

func (*ProfileStore) Get

func (store *ProfileStore) Get(id ID) *Profile

func (*ProfileStore) RestoreFromSnapshot

func (store *ProfileStore) RestoreFromSnapshot(path, filename string) error

func (*ProfileStore) Save

func (store *ProfileStore) Save(action *Action)

func (*ProfileStore) Snapshot

func (store *ProfileStore) Snapshot(path, filename string) error

type ProfileStoreFactory

type ProfileStoreFactory struct{}

func (ProfileStoreFactory) New

func (factory ProfileStoreFactory) New() *ProfileStore

type SelectionCacheInfo

type SelectionCacheInfo struct {
	CurrentIndex int
	MaximumIndex int
}

type Topic

type Topic uint64

Topic is represented by a hash of content keywords.

func (Topic) GetKeywords

func (t Topic) GetKeywords() (Keyword, Keyword)

Returns keywords from topic object. Keywords are always ordered in ASC.

type TopicFactory

type TopicFactory struct{}

func (TopicFactory) New

func (factory TopicFactory) New(k1, k2 Keyword) *Topic

Creates new Topic from keywords specified.

type TopicInterest

type TopicInterest struct {
	Topic              Topic
	Interest           Interest
	CumulativeInterest Interest
}

TopicInterest is a structure that represents the level of user's interest for specified topic.

func (*TopicInterest) Clone

func (topicInterest *TopicInterest) Clone() *TopicInterest

func (*TopicInterest) Describe

func (topicInterest *TopicInterest) Describe() *TopicInterestDescription

type TopicInterestBy

type TopicInterestBy func(t1, t2 *TopicInterest) bool

function that defines ordering between trend objects

func (TopicInterestBy) Sort

func (topicInterestBy TopicInterestBy) Sort(topicInterests TopicInterests)

method on the function type, sorts the argument slice according to the function

type TopicInterestDescription

type TopicInterestDescription struct {
	Keyword1           Keyword
	Keyword2           Keyword
	Interest           Interest
	CumulativeInterest Interest
}

type TopicInterestFactory

type TopicInterestFactory struct{}

func (*TopicInterestFactory) New

func (factory *TopicInterestFactory) New(topic Topic, cumulativeInterest Interest) *TopicInterest

type TopicInterests

type TopicInterests []*TopicInterest

Alias for a slice of pointers to topic interests.

func (TopicInterests) Apply

func (topicInterests TopicInterests) Apply(topics Topics, value float64) TopicInterests

value - between -1.0 and 1.0

func (TopicInterests) Clone

func (topicInterests TopicInterests) Clone() TopicInterests

func (TopicInterests) Describe

func (topicInterests TopicInterests) Describe() []*TopicInterestDescription

type Topics

type Topics []*Topic

type Trend

type Trend struct {
	Topic      Topic
	Popularity float64
}

func (*Trend) Describe

func (trend *Trend) Describe() *TrendDescription

type TrendBy

type TrendBy func(t1, t2 *Trend) bool

function that defines ordering between trend objects

func (TrendBy) Sort

func (trendBy TrendBy) Sort(trends []*Trend)

method on the function type, sorts the argument slice according to the function

type TrendDescription

type TrendDescription struct {
	Keyword1   Keyword
	Keyword2   Keyword
	Popularity float64
}

type TrendStore

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

func (*TrendStore) Describe

func (store *TrendStore) Describe() []*TrendDescription

func (*TrendStore) GetTopN

func (store *TrendStore) GetTopN(n int) Topics

func (*TrendStore) Register

func (store *TrendStore) Register(topics Topics, popularity float64)

func (*TrendStore) RestoreFromSnapshot

func (store *TrendStore) RestoreFromSnapshot(path, filename string) error

func (*TrendStore) Snapshot

func (store *TrendStore) Snapshot(path, filename string) error

func (*TrendStore) Unregister

func (store *TrendStore) Unregister(topics Topics, popularity float64)

type TrendStoreFactory

type TrendStoreFactory struct{}

func (TrendStoreFactory) New

func (factory TrendStoreFactory) New(bus *EventBus.EventBus) *TrendStore

type WordCount

type WordCount struct {
	Word  string
	Count float64
}

type WordCountBy

type WordCountBy func(c1, c2 *WordCount) bool

function that defines ordering between content objects

func (WordCountBy) Sort

func (wordCountBy WordCountBy) Sort(wordCounts []*WordCount)

method on the function type, sorts the argument slice according to the function

Jump to

Keyboard shortcuts

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