inputsample

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: 7 Imported by: 0

Documentation

Overview

Package inputsample provides an implementation of set.Sample that is read from an io.Reader.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(r io.Reader, features []feature.Feature, featureValueRequester FeatureValueRequester, undefinedValue string) set.Sample

New takes an io.Reader, a slice of features, a FeatureValueRequester and an undefinedValue coding string and returns a Sample.

The returned Sample ValueFor method reads feature values first requesting them with the given FeatureValueRequester and then parsing the values from the reader.

The parsing expects each value to be presented ending with the '\n' character, that is in new lines. Also, the undefinedValue string followed by the '\n' character will be interpreted as an undefined value.

For a feature.ContinuousFeature, lines will be read from the reader until a line containing a valid float64 number is found.

For a feature.DiscreteFeature, lines will be read from the reader until a line with a valid value for the feature is found.

For both kind of feature.Feature, non accepted values will be rejected with the FeatureValueRequester's RejectValueFor method.

Attempting to obtain a value for Feature not in the given features slice, or for another type of feature will return nil.

Types

type FeatureValueRequester

type FeatureValueRequester interface {
	RequestValueFor(feature.Feature) error
	RejectValueFor(feature.Feature, interface{}) error
}

FeatureValueRequester represents a way to ask for feature values and reject the given values.

Jump to

Keyboard shortcuts

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