示例#1
0
文件: main.go 项目: 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
}
示例#2
0
文件: initial.go 项目: postfix/HMM
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
}
示例#3
0
文件: main.go 项目: 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
}
示例#4
0
文件: main.go 项目: 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
}
示例#5
0
文件: transition.go 项目: postfix/HMM
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
}
示例#6
0
文件: transition.go 项目: postfix/HMM
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
}
示例#7
0
文件: trellis.go 项目: postfix/HMM
// String ...
func (r *Result) FormatString(s gologspace.Space) string {
	p := s.Exit(r.Prob)
	return fmt.Sprintf("'%v': %.8fp|", r.prevTag, p)
}