예제 #1
0
파일: main.go 프로젝트: postfix/HMM
func RunViterbiLog(sequence []string, c Config) {
	s := gologspace.LogSpace{}
	E := c.Emission(s)
	T := c.Transition(s)
	I := c.Initial(s)
	v := hmm.NewViterbi(c.Tags, sequence, s, &I, &T, &E)
	v.FillTrellis()
	fmt.Printf("%s\n", v)
}
예제 #2
0
파일: main.go 프로젝트: postfix/HMM
func BuildLabeled(sentences [][]string,
	tags []hmm.Tag, s gologspace.Space, i hmm.Initial,
	t hmm.Transition, e hmm.Emission) [][]hmm.LabeledWord {
	labeledSentences := make([][]hmm.LabeledWord, len(sentences))
	for iS, sentence := range sentences {
		v := hmm.NewViterbi(tags, sentence, s, &i, &t, &e)
		v.FillTrellis()
		labeled, err := v.Labeled()
		if err != nil {
			log.Printf("Failed Sentence: %v\n", len(sentence))
			log.Printf("Error: %v\n", err.Error())
			labeledSentences[iS] = make([]hmm.LabeledWord, 0)
		} else {
			labeledSentences[iS] = labeled
		}
		if iS%3000 == 0 {
			log.Println("Finished 3000 sentences")
		}
	}
	return labeledSentences
}