feature

package module
v0.0.0-...-201ecfc Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2017 License: BSD-3-Clause Imports: 5 Imported by: 0

README

maturity build status code coverage GoDoc

feature

The feature package implements a service for detecting patterns in information sequences.

Documentation

Overview

Package feature implements a service for detecting patterns in information sequences. A information sequence can be any string.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInvalidConfig

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

func IsInvalidExecution

func IsInvalidExecution(err error) bool

IsInvalidExecution asserts invalidExecutionError.

Types

type Config

type Config struct {

	// Positions represents the index locations of a detected feature.
	Positions [][]float64
	// Sequence represents the input sequence being detected as feature. That
	// means, the sequence of a feature is the actual conceptual feature itself.
	Sequence string
}

Config represents the configuration used to create a new feature.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig provides a default configuration to create a new feature by best effort.

type Feature

type Feature interface {
	// AddPosition provides a way to add more positions to the initialized
	// feature. Note positions are vectors in distribution terms.
	AddPosition(position []float64) error
	// Count returns the number of occurrences within analysed sequences. That is,
	// how often this feature was found. Technically spoken,
	// len(Feature.Positions).
	Count() int
	// Positions returns the feature's configured positions.
	Positions() [][]float64
	// Sequence returns the sequence that represents this feature. This is the
	// sub-sequence, the charactistic detected within analysed sequences.
	Sequence() string
}

Feature represents a charactistic within a sequence. During pattern recognition it is tried to detect features. Their distributions describe location patterns within space.

func New

func New(config Config) (Feature, error)

New creates a new configured feature.

type ScanConfig

type ScanConfig interface {
	// MaxLength returns the length maximum of a sequence detected as feature.
	// E.g. MaxLength set to 3 results in sequences having a length not larger
	// than 3 when detected as features. The value -1 disables any limitiation.
	MaxLength() int
	// MinLength returns the minimum length of a sequence detected as feature.
	// E.g. MinLength set to 3 results in sequences having a length not smaller
	// than 3 when detected as features. The value -1 disables any limitiation.
	MinLength() int
	// MinCount returns the number of occurrences at least required to be detected
	// as feature. E.g. MinCount set to 3 requires a feature to be present within
	// a given input sequence at least 3 times.
	MinCount() int
	// Separator returns the separator used to split sequences into smaller parts.
	// By default this is an empty string resulting in a character split. This can
	// be set to a whitespace to split for words. Note that the concept of words
	// is a feature known to humans based on contextual information humans
	// connected to create reasonable sences. This needs to be achieved by Anna
	// herself. So later this separator needs to be configured by Anna once she is
	// able to recognize improvements in feature detection, resulting in even more
	// awareness of contextual information.
	Separator() string
	// Sequences returns the input sequences being analysed. Out of this
	// information features are detected, if any.
	Sequences() []string
	SetMaxLength(maxLength int)
	SetMinLength(minLength int)
	SetMinCount(minCount int)
	SetSeparator(separate string)
	SetSequences(sequences []string)
	// Validate checks whether ScanConfig is valid for proper execution in
	// Feature.Scan.
	Validate() error
}

ScanConfig represents the configuration used to scan for new features.

func NewScanConfig

func NewScanConfig() ScanConfig

NewScanConfig creates a new configured scan config.

type Service

type Service interface {
	// Boot initializes and starts the whole service like booting a machine. The
	// call to Boot blocks until the service is completely initialized, so you
	// might want to call it in a separate goroutine.
	Boot()
	// Scan analyses the given sequences to detect patterns. Found patterns are
	// returned in form of a list of features.
	Scan(ctx context.Context, config ScanConfig) ([]Feature, error)
	// ScanConfig returns a default scan config configured by best effort.
	ScanConfig() ScanConfig
	// Shutdown ends all processes of the service like shutting down a machine.
	// The call to Shutdown blocks until the service is completely shut down, so
	// you might want to call it in a separate goroutine.
	Shutdown()
}

Service represents a service being able to scan for features within information sequences.

func NewService

func NewService(config ServiceConfig) (Service, error)

NewService creates a new configured service.

type ServiceConfig

type ServiceConfig struct {
}

ServiceConfig represents the configuration used to create a new service.

func DefaultServiceConfig

func DefaultServiceConfig() ServiceConfig

DefaultServiceConfig provides a default configuration to create a new service by best effort.

Jump to

Keyboard shortcuts

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