Exemplo n.º 1
0
Arquivo: main.go Projeto: postfix/HMM
func (c *Config) Initial(s gologspace.Space) hmm.Initial {
	e := hmm.Initial{}
	for tag, p := range c.I {
		e[tag] = s.Enter(p)
	}
	return e
}
Exemplo n.º 2
0
func UniformI(tags []Tag, s gologspace.Space) Initial {
	iS := make(Initial)
	length := float64(len(tags))
	size := s.Enter(length)
	one := s.Enter(1.0)
	for _, tag := range tags {
		iS[tag] = one / size
	}
	return iS
}
Exemplo n.º 3
0
Arquivo: main.go Projeto: postfix/HMM
func (c *Config) Emission(s gologspace.Space) hmm.Emission {
	e := hmm.Emission{}
	for tag, probs := range c.E {
		p := make(map[string]float64)
		for word, prob := range probs {
			p[word] = s.Enter(prob)
		}
		e[tag] = p
	}
	return e
}
Exemplo n.º 4
0
Arquivo: main.go Projeto: postfix/HMM
func (c *Config) Transition(s gologspace.Space) hmm.Transition {
	e := hmm.Transition{}
	for tag1, probs := range c.T {
		p := make(map[hmm.Tag]float64)
		for tag2, prob := range probs {
			p[tag2] = s.Enter(prob)
		}
		e[tag1] = p
	}
	return e
}
Exemplo n.º 5
0
func UniformT2(tags TCache, s gologspace.Space) Transition {
	t := make(Transition)
	one := s.Enter(1.0)
	for tag1, nTags := range tags {
		t[tag1] = make(map[Tag]float64)
		length := float64(len(nTags))
		size := s.Enter(length)
		for tag2, _ := range nTags {
			t[tag1][tag2] = one / size
		}
	}
	return t
}
Exemplo n.º 6
0
func UniformT(tags []Tag, s gologspace.Space) Transition {
	t := make(Transition)
	length := float64(len(tags))
	size := s.Enter(length)
	one := s.Enter(1.0)
	for _, tag1 := range tags {
		t[tag1] = make(map[Tag]float64)
		for _, tag2 := range tags {
			t[tag1][tag2] = one / size
		}
	}
	return t
}
Exemplo n.º 7
0
// String ...
func (r *Result) FormatString(s gologspace.Space) string {
	p := s.Exit(r.Prob)
	return fmt.Sprintf("'%v': %.8fp|", r.prevTag, p)
}