Example #1
0
func (s *Stemmer) Process(input tokenizer.TokenChan) tokenizer.TokenChan {
	return filter.StartFilter(input, func(token *tokenizer.Token, output tokenizer.TokenChan) {
		str := token.Backing()
		cs := C.CString(str)
		defer C.free(unsafe.Pointer(cs))
		end := C.stem(s.cstemmer, cs, C.int(len(str)-1)) + 1
		output <- tokenizer.NewToken(str[0:end])
	})
}
Example #2
0
func (ps *PorterStemmer) Stem(s string) string {
	cs := C.CString(s)
	defer C.free(unsafe.Pointer(cs))
	end := C.stem(ps.cstemmer, cs, C.int(len(s)-1)) + 1
	return s[0:end]
}