feature

package
v0.0.0-...-dbea759 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package feature defines features and criteria for those features

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContinuousCriterion

type ContinuousCriterion interface {
	Criterion
	Interval() (float64, float64)
}

ContinuousCriterion represents a constraint on a continuous feature, a range that delimits which values it may take. The interval can be open on one end, thus representing -Infinity or +Infinity

Its Interval method returns the start and end of the interval to which the feature is constrained as a pair of float64 values.

func NewContinuousCriterion

func NewContinuousCriterion(feature *ContinuousFeature, a float64, b float64) ContinuousCriterion

NewContinuousCriterion takes a ContinuousFeature feature and a pair of float64 values indicating the start and the end of an interval and return a ContinuousCriterion with the feature and interval. The interval can be open on any end by providing -Inf and/or +Inf.

type ContinuousFeature

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

ContinuousFeature represents a property that can be observed and that can take a numeric value

func NewContinuousFeature

func NewContinuousFeature(name string) *ContinuousFeature

NewContinuousFeature takes a name string and returns a continuous feature with the given name.

func (*ContinuousFeature) Name

func (cf *ContinuousFeature) Name() string

Name returns a string with the name of the feature

func (*ContinuousFeature) String

func (cf *ContinuousFeature) String() string

func (*ContinuousFeature) Valid

func (cf *ContinuousFeature) Valid(value interface{}) (bool, error)

Valid receives an interface value and returns a boolean and an error. When the value parameter is a float64 it returns true and nil, otherwise it returns false and an error describing the reason.

type Criterion

type Criterion interface {
	Feature() Feature
	SatisfiedBy(sample Sample) (bool, error)
}

Criterion represents a constraint on a feature

Its SatisfiedBy method takes a sample and returns a boolean indicating if the given value satisfies the feature criterion.

Its Feature method returns the feature on which the criterion is applied.

type DiscreteCriterion

type DiscreteCriterion interface {
	Criterion
	Value() string
}

DiscreteCriterion represents a constraint on a discrete feature, a value it may take.

Its Value method returns the value to which the feature is constrained as a string.

func NewDiscreteCriterion

func NewDiscreteCriterion(feature *DiscreteFeature, value string) DiscreteCriterion

NewDiscreteCriterion takes a DiscreteFeature feature and a pair of float64 values indicating the start and the end of an interval and return a DiscreteCriterion with the feature and interval. The interval can be open on any end by providing -Inf and/or +Inf.

type DiscreteFeature

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

DiscreteFeature represents a property that can be observed and that can only take a value among a finite set.

func NewDiscreteFeature

func NewDiscreteFeature(name string, availableValues []string) *DiscreteFeature

NewDiscreteFeature takes a name string and a slice of available value strings and returns a discrete feature with the given names and available values.

func (*DiscreteFeature) AvailableValues

func (df *DiscreteFeature) AvailableValues() []string

AvailableValues returns a string slice with the values available for the feature

func (*DiscreteFeature) Name

func (df *DiscreteFeature) Name() string

Name returns a string with the name of the feature

func (*DiscreteFeature) String

func (df *DiscreteFeature) String() string

func (*DiscreteFeature) Valid

func (df *DiscreteFeature) Valid(value interface{}) (bool, error)

Valid receives an interface value and returns a boolean and an error. When the value parameter is included in the available values fo the feature, the method returns true and nil. Otherwise it returns false and an error describing the reason.

type Feature

type Feature interface {
	Name() string
	Valid(interface{}) (bool, error)
}

Feature represents a property that can be observed

type Sample

type Sample interface {
	ValueFor(Feature) (interface{}, error)
}

Sample is an interface for something that can satisfy a Criterion.

Its ValueFor method returns the value corresponding to the feature passed as parameter.

type UndefinedCriterion

type UndefinedCriterion interface {
	Criterion
	IsUndefinedCriterion() bool
}

UndefinedCriterion represents the lack of constraint on a specific feature.

func NewUndefinedCriterion

func NewUndefinedCriterion(f Feature) UndefinedCriterion

NewUndefinedCriterion takes a Feature and returns a Criterion that is always satisfied.

Directories

Path Synopsis
Package yaml provides methods to parse feature.Feature specifications also known as metadata, from YAML documents.
Package yaml provides methods to parse feature.Feature specifications also known as metadata, from YAML documents.

Jump to

Keyboard shortcuts

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