Ejemplo n.º 1
0
// Reports entity mentions in s according to a best path (Viterbi) algorithm.
//
// This gets rid of overlapping candidates.
func (sem Semanticizer) BestPath(s string) ([]Entity, error) {
	tokens, tokpos := nlp.TokenizePos(s)
	if len(tokens) == 0 {
		return nil, nil
	}
	all, err := sem.allFromTokens(tokens, tokpos)
	if err != nil {
		return nil, err
	}
	return bestPath(all), nil
}
Ejemplo n.º 2
0
// Get all candidate entity mentions in the string s.
func (sem Semanticizer) All(s string) (cands []Entity, err error) {
	tokens, tokpos := nlp.TokenizePos(s)
	return sem.allFromTokens(tokens, tokpos)
}