Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseComponent ¶
type BaseComponent struct {
// contains filtered or unexported fields
}
BaseComponent 基础评分组件
func (*BaseComponent) IsAutoWeight ¶
func (b *BaseComponent) IsAutoWeight() bool
func (*BaseComponent) Name ¶
func (b *BaseComponent) Name() string
func (*BaseComponent) Score ¶
func (b *BaseComponent) Score() (float64, error)
func (*BaseComponent) SetSystem ¶
func (b *BaseComponent) SetSystem(s *ScoringSystem)
func (*BaseComponent) Weight ¶
func (b *BaseComponent) Weight() float64
type ComponentOption ¶
type ComponentOption func(*BaseComponent)
ComponentOption 组件选项
func WithCustomWeight ¶
func WithCustomWeight(w float64) ComponentOption
func WithProcessor ¶
func WithProcessor(p DataProcessor, data interface{}) ComponentOption
type DataProcessor ¶
DataProcessor 数据处理器接口
type RangeProcessor ¶
type RangeProcessor struct {
Min, Max float64
}
RangeProcessor 示例处理器
func (*RangeProcessor) Process ¶
func (p *RangeProcessor) Process(data interface{}) (float64, error)
type ScoreComponent ¶
type ScoreComponent interface {
Name() string
Weight() float64
Score() (float64, error)
SetSystem(*ScoringSystem)
IsAutoWeight() bool
}
ScoreComponent 评分组件接口
func NewComponent ¶
func NewComponent(name string, opts ...ComponentOption) ScoreComponent
type ScoringSystem ¶
type ScoringSystem struct {
Components []ScoreComponent
// contains filtered or unexported fields
}
ScoringSystem 评分系统
func GetScoringSystem ¶
func GetScoringSystem() *ScoringSystem
func (*ScoringSystem) CalculateTotalScore ¶
func (s *ScoringSystem) CalculateTotalScore() (float64, error)
func (*ScoringSystem) Register ¶
func (s *ScoringSystem) Register(c ScoreComponent) error
type ThresholdProcessor ¶
type ThresholdProcessor struct {
Threshold float64
}
ThresholdProcessor 阀值处理器
func (*ThresholdProcessor) Process ¶
func (p *ThresholdProcessor) Process(data interface{}) (float64, error)
Click to show internal directories.
Click to hide internal directories.