search

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_TRANSITIONS = 800
)

Variables

View Source
var (
	AgendaOut bool = false
	ShowFeats bool = false
)
View Source
var AllOut bool = true
View Source
var SHOW_ORACLE = false

Functions

func ArrayDiff

func ArrayDiff(left []featurevector.Feature, right []featurevector.Feature) ([]string, []string)

func CompareConf

func CompareConf(confA, confB *ScoredConfiguration, reverse bool) bool

func SearchEarlyUpdate

func SearchEarlyUpdate(b Interface, problem Problem, B int, goldSequence Candidates) (Candidate, Candidate)

Types

type Agenda

type Agenda interface {
	AddCandidates([]Candidate, Candidate, int) (Candidate, int)
	Contains(Candidate) bool
	Len() int
	Clear()
}

type Aligned

type Aligned interface {
	Alignment() int
}

type AssignmentScore

type AssignmentScore struct {
	Total  int64
	Number uint16
}

func (*AssignmentScore) Add

func (a *AssignmentScore) Add(value int64)

func (*AssignmentScore) Average

func (a *AssignmentScore) Average() float64

type BaseAgenda

type BaseAgenda struct {
	sync.Mutex
	HeapReverse bool
	BeamSize    int
	Confs       []*ScoredConfiguration
	ShowSwap    bool
}

func NewAgenda

func NewAgenda(size int) *BaseAgenda

func (*BaseAgenda) AddCandidate

func (a *BaseAgenda) AddCandidate(c, best Candidate) Candidate

func (*BaseAgenda) AddCandidates

func (a *BaseAgenda) AddCandidates(cs []Candidate, curBest Candidate, minAlignment int) (Candidate, int)

func (*BaseAgenda) CandidateStr

func (a *BaseAgenda) CandidateStr(c *ScoredConfiguration) string

func (*BaseAgenda) Clear

func (a *BaseAgenda) Clear()

func (*BaseAgenda) ConfStr

func (a *BaseAgenda) ConfStr() string

func (*BaseAgenda) Contains

func (a *BaseAgenda) Contains(goldCandidate Candidate) bool

func (*BaseAgenda) Copy

func (a *BaseAgenda) Copy(i, j int)

func (*BaseAgenda) Get

func (a *BaseAgenda) Get(i int) interface{}

func (*BaseAgenda) Len

func (a *BaseAgenda) Len() int

func (*BaseAgenda) Less

func (a *BaseAgenda) Less(i, j int) bool

func (*BaseAgenda) LessValue

func (a *BaseAgenda) LessValue(i int, x interface{}) bool

func (*BaseAgenda) Peek

func (a *BaseAgenda) Peek() *ScoredConfiguration

func (*BaseAgenda) Pop

func (a *BaseAgenda) Pop() interface{}

func (*BaseAgenda) Push

func (a *BaseAgenda) Push(x interface{})

func (*BaseAgenda) ReEnumerate

func (a *BaseAgenda) ReEnumerate()

func (*BaseAgenda) Reverse

func (a *BaseAgenda) Reverse()

func (*BaseAgenda) Set

func (a *BaseAgenda) Set(i int, x interface{})

func (*BaseAgenda) String

func (a *BaseAgenda) String() string

func (*BaseAgenda) Swap

func (a *BaseAgenda) Swap(i, j int)

type Beam

type Beam struct {
	// main beam functions and parameters
	Base          transition.Configuration
	TransFunc     transition.TransitionSystem
	FeatExtractor perceptron.FeatureExtractor
	Model         TransitionModel.Interface

	Size                 int
	EstimatedTransitions int
	EarlyUpdateAt        int

	// flags
	Averaged           bool
	DecodeTest         bool // set to true when decoding is 'testing' during learning process
	ReturnModelValue   bool
	ReturnSequence     bool
	ShowConsiderations bool
	ConcurrentExec     bool
	Log                bool
	ShortTempAgenda    bool
	NoRecover          bool
	Align              bool

	DurTotal time.Duration

	// used for debug output
	Transitions *util.EnumSet

	IntegrationGeneration int
	ScoredStoreDense      bool
	// contains filtered or unexported fields
}

func (*Beam) Aligned

func (b *Beam) Aligned() bool

func (*Beam) Best

func (b *Beam) Best(a Agenda) Candidate

func (*Beam) Clear

func (b *Beam) Clear(agenda Agenda) Agenda

func (*Beam) Concurrent

func (b *Beam) Concurrent() bool

func (*Beam) DecodeEarlyUpdate

func (b *Beam) DecodeEarlyUpdate(goldInstance perceptron.DecodedInstance, m perceptron.Model) (perceptron.DecodedInstance, interface{}, interface{}, int, int, float64)

func (*Beam) Expand

func (b *Beam) Expand(c Candidate, p Problem, candidateNum int) chan Candidate

func (*Beam) GoalTest

func (b *Beam) GoalTest(p Problem, c Candidate, rounds int) bool

func (*Beam) Idle

func (b *Beam) Idle(c Candidate, candidateNum int) Candidate

func (*Beam) Insert

func (b *Beam) Insert(cs chan Candidate, a Agenda) []Candidate

func (*Beam) Name

func (b *Beam) Name() string

func (*Beam) Parse

func (b *Beam) Parse(problem Problem) (transition.Configuration, interface{})

func (*Beam) SetEarlyUpdate

func (b *Beam) SetEarlyUpdate(i int)

func (*Beam) StartItem

func (b *Beam) StartItem(p Problem) []Candidate

func (*Beam) Top

func (b *Beam) Top(a Agenda) Candidate

func (*Beam) TopB

func (b *Beam) TopB(a Agenda, B int) ([]Candidate, bool)

type Candidate

type Candidate interface {
	Copy() Candidate
	Equal(Candidate) bool
	Score() float64
	Len() int
	Terminal() bool
}
func Search(b Interface, problem Problem, B int) Candidate

type Candidates

type Candidates interface {
	Get(int) Candidate
	Len() int
}

type Deterministic

type Deterministic struct {
	Model              TransitionModel.Interface
	TransFunc          transition.TransitionSystem
	FeatExtractor      perceptron.FeatureExtractor
	ReturnModelValue   bool
	ReturnSequence     bool
	ShowConsiderations bool
	Base               transition.Configuration
	NoRecover          bool
	TransEnum          *util.EnumSet
	DefaultTransType   byte
}

func (*Deterministic) Decode

func (d *Deterministic) Decode(instance perceptron.Instance, m perceptron.Model) (perceptron.DecodedInstance, interface{})

Perceptron functions

func (*Deterministic) DecodeEarlyUpdate

func (d *Deterministic) DecodeEarlyUpdate(goldInstance perceptron.DecodedInstance, m perceptron.Model) (perceptron.DecodedInstance, interface{}, interface{}, int, int, int64)

func (*Deterministic) DecodeGold

func (d *Deterministic) DecodeGold(goldInstance perceptron.DecodedInstance, m perceptron.Model) (perceptron.DecodedInstance, interface{})

func (*Deterministic) Parse

func (d *Deterministic) Parse(problem Problem) (transition.Configuration, interface{})

Parser functions

func (*Deterministic) ParseOracle

func (d *Deterministic) ParseOracle(gold perceptron.DecodedInstance) (configuration transition.Configuration, result interface{})

func (*Deterministic) ParseOracleEarlyUpdate

func (d *Deterministic) ParseOracleEarlyUpdate(sent nlp.Sentence, gold transition.ConfigurationSequence, constraints interface{}, model dependency.ParameterModel) (transition.Configuration, transition.Configuration, interface{}, interface{}, int)

type Idle

type Idle interface {
	Idle(c Candidate, candidateNum int) Candidate
}

type IdleFunc

type IdleFunc func(c Candidate, candidateNum int) Candidate

type Interface

type Interface interface {
	StartItem(p Problem) []Candidate
	Clear(Agenda) Agenda
	Insert(cs chan Candidate, a Agenda) []Candidate //Agenda
	Expand(c Candidate, p Problem, candidateNum int) chan Candidate
	Top(a Agenda) Candidate
	Best(a Agenda) Candidate
	GoalTest(p Problem, c Candidate, rounds int) bool
	TopB(a Agenda, B int) ([]Candidate, bool)
	Concurrent() bool
	SetEarlyUpdate(int)

	Name() string
	Aligned() bool
}

type ParseResultParameters

type ParseResultParameters struct {
	ModelValue interface{}
	Sequence   transition.ConfigurationSequence
}

type PerceptronModel

type PerceptronModel struct {
	PerceptronModel TransitionModel.Interface
}

func (*PerceptronModel) Model

func (p *PerceptronModel) Model() interface{}

func (*PerceptronModel) TransitionModel

func (p *PerceptronModel) TransitionModel() TransitionModel.Interface

type PerceptronModelValue

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

func (*PerceptronModelValue) Clear

func (pmv *PerceptronModelValue) Clear()

type Problem

type Problem interface{}

type ScoreState

type ScoreState []AssignmentScore

func NewScoreState

func NewScoreState() ScoreState

func (*ScoreState) Add

func (s *ScoreState) Add(score int64, assignment uint16)

func (ScoreState) Average

func (s ScoreState) Average() float64

func (ScoreState) Copy

func (s ScoreState) Copy() ScoreState

func (ScoreState) Total

func (s ScoreState) Total() float64

type ScoredConfiguration

type ScoredConfiguration struct {
	C              transition.Configuration
	Transition     transition.Transition
	InternalScores ScoreState
	Features       *transition.FeaturesList

	CandidateNum, TransNum int
	Expanded               bool
	Averaged               bool
}

func (*ScoredConfiguration) AddScore

func (s *ScoredConfiguration) AddScore(newScore int64, assignment uint16)

func (*ScoredConfiguration) Alignment

func (s *ScoredConfiguration) Alignment() int

func (*ScoredConfiguration) Clear

func (s *ScoredConfiguration) Clear()

func (*ScoredConfiguration) Copy

func (s *ScoredConfiguration) Copy() Candidate

func (*ScoredConfiguration) Equal

func (s *ScoredConfiguration) Equal(otherEq Candidate) bool

func (*ScoredConfiguration) Expand

func (*ScoredConfiguration) Len

func (s *ScoredConfiguration) Len() int

func (*ScoredConfiguration) Score

func (s *ScoredConfiguration) Score() float64

func (*ScoredConfiguration) String

func (s *ScoredConfiguration) String() string

func (*ScoredConfiguration) Terminal

func (s *ScoredConfiguration) Terminal() bool

type ScoredConfigurations

type ScoredConfigurations []*ScoredConfiguration

func (ScoredConfigurations) Equal

func (scs ScoredConfigurations) Equal(otherEq util.Equaler) bool

func (ScoredConfigurations) Get

func (scs ScoredConfigurations) Get(i int) Candidate

func (ScoredConfigurations) Len

func (scs ScoredConfigurations) Len() int

type TransitionClassifier

type TransitionClassifier struct {
	Model              dependency.TransitionParameterModel
	TransFunc          transition.TransitionSystem
	FeatExtractor      perceptron.FeatureExtractor
	Score              int64
	FeaturesList       *transition.FeaturesList
	ShowConsiderations bool
}

func (*TransitionClassifier) Init

func (tc *TransitionClassifier) Init()

func (*TransitionClassifier) ScoreWithConf

func (tc *TransitionClassifier) ScoreWithConf(c transition.Configuration) int64
func (tc *TransitionClassifier) Increment(c transition.Configuration) *TransitionClassifier {
	features := tc.FeatExtractor.Features(perceptron.Instance(c), false, nil)
	tc.FeaturesList = &transition.FeaturesList{features, c.GetLastTransition(), tc.FeaturesList}
	tc.Score += tc.Model.TransitionScore(c.GetLastTransition(), features)
	return tc
}

func (*TransitionClassifier) Transition

func (*TransitionClassifier) TransitionWithConf

Jump to

Keyboard shortcuts

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